Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion brukerapi/config/properties_2dseq_core.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pv_version": [
{
"cmd": "#VisuCreatorVersion[1:-1].split(';')[0]",
"cmd": "(#VisuCreatorVersion).split(';')[0]",
"conditions": [],
"comment": "spec 7.1: VisuCreator/VisuCreatorVersion are semicolon-separated lists; the first creator is the one that wrote the dataset"
}
Expand Down
6 changes: 3 additions & 3 deletions brukerapi/config/properties_2dseq_custom.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"subj_id": [
{
"cmd": "#VisuSubjectName[1:-1]",
"cmd": "#VisuSubjectName",
"conditions": [
]
},
Expand Down Expand Up @@ -158,13 +158,13 @@
],
"date": [
{
"cmd": "datetime.datetime.strptime(#VisuStudyDate[1:-1], '%X %d %b %Y')",
"cmd": "datetime.datetime.strptime(#VisuStudyDate, '%X %d %b %Y')",
"conditions": [
"'T' not in #VisuStudyDate"
]
},
{
"cmd": "datetime.datetime.strptime(#VisuStudyDate[1:-1], '%Y-%m-%dT%X,%f%z')",
"cmd": "datetime.datetime.strptime(#VisuStudyDate, '%Y-%m-%dT%X,%f%z')",
"conditions": [
"'T' in #VisuStudyDate"
]
Expand Down
66 changes: 33 additions & 33 deletions brukerapi/config/properties_fid_core.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pv_version": [
{
"cmd": "#ACQ_sw_version[1:-1].replace('PV-','').replace('PV ','').strip()",
"cmd": "(#ACQ_sw_version).replace('PV-','').replace('PV ','').strip()",
"conditions": [],
"comment": "spec 7.1/13: version gates compare on this parsed version, so an unlisted point release is not silently unsupported"
},
Expand Down Expand Up @@ -131,7 +131,7 @@
{
"cmd": "#ACQ_size.tuple[0] * @channels",
"conditions": [
["#PULPROG", ["<SPIRAL.ppg>","<DtiSpiral.ppg>"]],
["#PULPROG", ["SPIRAL.ppg","DtiSpiral.ppg"]],
"@pv_version.split('.')[0]=='5'"
]
},
Expand Down Expand Up @@ -161,23 +161,23 @@
"conditions": [
["#PULPROG",
[
"<FLASH.ppg>",
"<FLASHAngio.ppg>",
"<RAREVTR.ppg>",
"<MGE.ppg>",
"<RARE.ppg>",
"<FLASHAngio.ppg>",
"<FcFLASH.ppg>",
"<DtiStandard.ppg>",
"<FISP.ppg>",
"<MSME.ppg>",
"<FAIR_RARE.ppg>",
"<RAREst.ppg>",
"<FLOWMAP.ppg>",
"<MDEFT.ppg>",
"<igFLASH.ppg>",
"<B1Map.ppg>",
"<DESS.ppg>"
"FLASH.ppg",
"FLASHAngio.ppg",
"RAREVTR.ppg",
"MGE.ppg",
"RARE.ppg",
"FLASHAngio.ppg",
"FcFLASH.ppg",
"DtiStandard.ppg",
"FISP.ppg",
"MSME.ppg",
"FAIR_RARE.ppg",
"RAREst.ppg",
"FLOWMAP.ppg",
"MDEFT.ppg",
"igFLASH.ppg",
"B1Map.ppg",
"DESS.ppg"
]
],
"#ACQ_dim==2"
Expand All @@ -186,7 +186,7 @@
{
"cmd": "'CART_3D'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"FLASH.ppg",
"FLASHAngio.ppg",
Expand All @@ -203,7 +203,7 @@
{
"cmd": "'FIELD_MAP'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"FieldMap.ppg"
]
Expand All @@ -213,7 +213,7 @@
{
"cmd": "'RADIAL'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"UTE.ppg",
"UTE3D.ppg"
Expand All @@ -224,7 +224,7 @@
{
"cmd": "'EPI'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"EPI.ppg",
"navigatorEPI_OM.ppg",
Expand All @@ -240,7 +240,7 @@
{
"cmd": "'dEPI'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"DtiEpi.ppg",
"EPSI.ppg"
Expand All @@ -251,7 +251,7 @@
{
"cmd": "'SPECTROSCOPY'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"PRESS.ppg",
"STEAM.ppg",
Expand All @@ -269,7 +269,7 @@
{
"cmd": "'CSI'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"CSI.ppg"
]
Expand All @@ -279,7 +279,7 @@
{
"cmd": "'SPIRAL'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"SPIRAL.ppg",
"DtiSpiral.ppg"
Expand All @@ -290,7 +290,7 @@
{
"cmd": "'ZTE'" ,
"conditions": [
["#PULPROG[1:-1]",
["#PULPROG",
[
"ZTE.ppg"
]
Expand Down Expand Up @@ -342,7 +342,7 @@
"cmd": "#NSegments*#ACQ_size[2]*#NI*#NR",
"conditions": [
"#GO_block_size!='Standard_KBlock_Format'",
"#PULPROG[1:-1]=='EPSI.ppg'"
"#PULPROG=='EPSI.ppg'"
]
},
{
Expand Down Expand Up @@ -484,7 +484,7 @@
],
"conditions": [
"#GO_block_size!='Standard_KBlock_Format'",
"#PULPROG[1:-1]=='EPSI.ppg'"
"#PULPROG=='EPSI.ppg'"
]
},
{
Expand Down Expand Up @@ -616,7 +616,7 @@
"cmd": [0,4,3,2,1],
"conditions": [
"#GO_block_size!='Standard_KBlock_Format'",
"#PULPROG[1:-1]=='EPSI.ppg'"
"#PULPROG=='EPSI.ppg'"
]
},
{
Expand Down Expand Up @@ -726,7 +726,7 @@
],
"conditions": [
"#GO_block_size!='Standard_KBlock_Format'",
"#PULPROG[1:-1]=='EPSI.ppg'"
"#PULPROG=='EPSI.ppg'"
],
"comment": "spec 6.3: matches RECO_inp_size -- read x phase x spectral points x receivers"
},
Expand Down Expand Up @@ -853,7 +853,7 @@
],
"conditions": [
"#GO_block_size!='Standard_KBlock_Format'",
"#PULPROG[1:-1]=='EPSI.ppg'"
"#PULPROG=='EPSI.ppg'"
]
},
{
Expand Down
6 changes: 3 additions & 3 deletions brukerapi/config/properties_fid_custom.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"subj_id": [
{
"cmd": "#SUBJECT_id[1:-1]",
"cmd": "#SUBJECT_id",
"conditions": [

]
Expand Down Expand Up @@ -50,13 +50,13 @@
],
"date": [
{
"cmd": "datetime.datetime.strptime(#ACQ_time,'<%Y-%m-%dT%X,%f%z>')",
"cmd": "datetime.datetime.strptime(#ACQ_time,'%Y-%m-%dT%X,%f%z')",
"conditions": [
"'T' in #ACQ_time"
]
},
{
"cmd": "datetime.datetime.strptime(#ACQ_time,'<%H:%M:%S %d %b %Y>')",
"cmd": "datetime.datetime.strptime(#ACQ_time,'%H:%M:%S %d %b %Y')",
"conditions": [
"'T' not in #ACQ_time"
]
Expand Down
4 changes: 2 additions & 2 deletions brukerapi/config/properties_rawdata_core.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"pv_version": [
{
"cmd": "#ACQ_sw_version[1:-1].replace('PV-','').replace('PV ','').strip()",
"cmd": "(#ACQ_sw_version).replace('PV-','').replace('PV ','').strip()",
"conditions": [],
"comment": "spec 7.1/13: version gates compare on this parsed version, so an unlisted point release is not silently unsupported"
},
Expand All @@ -12,7 +12,7 @@
],
"job_desc": [
{
"cmd": "[v for v in #ACQ_jobs.nested if v[-1] == '<{}>'.format(@subtype)][0]",
"cmd": "[v for v in #ACQ_jobs.nested if v[-1] == @subtype][0]",
"conditions": [
"len(#ACQ_jobs.nested[0])==9"
]
Expand Down
2 changes: 1 addition & 1 deletion brukerapi/config/properties_rawdata_custom.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"subj_id": [
{
"cmd": "#SUBJECT_id[1:-1]",
"cmd": "#SUBJECT_id",
"conditions": [

]
Expand Down
6 changes: 3 additions & 3 deletions brukerapi/config/properties_traj_core.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"cmd": "'RADIAL'",
"conditions": [
[
"#PULPROG[1:-1]",
"#PULPROG",
[
"UTE.ppg",
"UTE3D.ppg",
Expand All @@ -23,7 +23,7 @@
"cmd": "'SPIRAL'",
"conditions": [
[
"#PULPROG[1:-1]",
"#PULPROG",
[
"SPIRAL.ppg",
"DtiSpiral.ppg"
Expand All @@ -35,7 +35,7 @@
"cmd": "'ZTE'",
"conditions": [
[
"#PULPROG[1:-1]",
"#PULPROG",
[
"ZTE.ppg"
]
Expand Down
2 changes: 1 addition & 1 deletion brukerapi/config/properties_traj_custom.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"subj_id": [
{
"cmd": "#SUBJECT_id[1:-1]",
"cmd": "#SUBJECT_id",
"conditions": []
},
{
Expand Down
19 changes: 9 additions & 10 deletions brukerapi/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,7 @@ def _rawdata_job_index(self):
if not jobs:
return None
if len(jobs[0]) == 9:
title = f"<{self.subtype}>"
return next((index for index, job in enumerate(jobs) if job[-1] == title), None)
return next((index for index, job in enumerate(jobs) if job[-1] == self.subtype), None)
try:
return int(self.subtype.removeprefix("job"))
except ValueError:
Expand All @@ -628,7 +627,7 @@ def rawdata_job_settings(self):
def rawdata_job_discarded(self):
"""Whether §13.1 says this job's data is intentionally not written."""
settings = self.rawdata_job_settings
return bool(settings and str(settings[0]).strip("<>") == "STORE_discard")
return bool(settings and str(settings[0]) == "STORE_discard")

@property
def rawdata_stored_scans(self):
Expand Down Expand Up @@ -663,7 +662,7 @@ def rawdata_channels(self):
fallback = int(self._parameter_value("PVM_EncNReceivers", 1))
if selected is not None:
values = np.atleast_1d(selected)
channels = sum(str(value).strip("<>").casefold() in {"yes", "on", "1"} for value in values)
channels = sum(str(value).casefold() in {"yes", "on", "1"} for value in values)
# Some systems expose more physical receiver paths than the job
# writes. Only promote the per-channel declaration when it agrees
# with the method's logical receiver count.
Expand All @@ -674,8 +673,8 @@ def rawdata_channels(self):
def _infer_scheme_id(self):
# Source of truth for format inference:
# https://github.com/gdevenyi/brkraw-legacy/blob/main/FILE_FORMAT.md
pulprog = str(self._parameter_value("PULPROG", "")).strip("<>").upper()
method = str(self._parameter_value("Method", "")).strip("<>").upper()
pulprog = str(self._parameter_value("PULPROG", "")).upper()
method = str(self._parameter_value("Method", "")).upper()
family = f"{pulprog} {method}"

if "SPIRAL" in family or self._parameter_value("PVM_SpiralNbOfInterleaves") is not None:
Expand Down Expand Up @@ -1172,7 +1171,7 @@ def _frame_geometry(self):
if orientation.shape[1] != 9 or position.shape[1] != 3:
raise UnsupportedDatasetType(f"an image affine for {self.path}, whose frames carry no 3x3 orientation and 3-vector position (spec 7.2),")

disk_order = str(self._parameter_value("VisuCoreDiskSliceOrder", "")).strip("<>").lower()
disk_order = str(self._parameter_value("VisuCoreDiskSliceOrder", "")).lower()
if disk_order == "disk_reverse_slice_order" and int(self._parameter_value("VisuCoreDim", 2)) < 3 and position.shape[0] > 1:
position = position[::-1]
if orientation.shape[0] == position.shape[0]:
Expand Down Expand Up @@ -1357,14 +1356,14 @@ def frame_group_values(self):
for descriptor in descriptors:
try:
vals_start, vals_count = int(descriptor[3]), int(descriptor[4])
group_name = str(descriptor[1]).strip("<>")
axis = next(axis for axis, dim_type in enumerate(self.dim_type) if str(dim_type).strip("<>") == group_name)
group_name = str(descriptor[1])
axis = next(axis for axis, dim_type in enumerate(self.dim_type) if str(dim_type) == group_name)
except (IndexError, StopIteration, TypeError, ValueError):
continue
for index in range(vals_start, vals_start + vals_count):
if not (0 <= index < len(dependencies)) or len(dependencies[index]) < 2:
continue
grouped.setdefault(str(dependencies[index][0]).strip("<>"), []).append(axis)
grouped.setdefault(str(dependencies[index][0]), []).append(axis)

values = {}
data_shape = self._data.shape
Expand Down
Loading