From 30aba93c69fe4f2631998e11144d2ffbc3a3b871 Mon Sep 17 00:00:00 2001 From: Vasilis Karlaftis Date: Wed, 28 Jan 2026 00:39:22 +0000 Subject: [PATCH 1/3] [skip ci] adding 'fid_proc" format and various bug fixes --- brukerapi/config/properties_fid_custom.json | 2 +- brukerapi/dataset.py | 33 +++++++++++++++++---- brukerapi/schemas.py | 14 +++++++++ 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/brukerapi/config/properties_fid_custom.json b/brukerapi/config/properties_fid_custom.json index 5b40143..839276a 100644 --- a/brukerapi/config/properties_fid_custom.json +++ b/brukerapi/config/properties_fid_custom.json @@ -71,7 +71,7 @@ "dwell_s": [ { "cmd": "1./ @sw_hz / 2.", - "conditions": [] + "conditions": ["@sw_hz!=0"] } ], "TR": [ diff --git a/brukerapi/dataset.py b/brukerapi/dataset.py index 842915c..885e95c 100644 --- a/brukerapi/dataset.py +++ b/brukerapi/dataset.py @@ -28,6 +28,15 @@ "load": LOAD_STAGES['all'], "mmap": False }, + 'fid_proc': { + "parameter_files" : ['acqp', 'method'], + "property_files": [ + Path(__file__).parents[0] / 'config/properties_fid_core.json', + Path(__file__).parents[0] / 'config/properties_fid_custom.json' + ], + "load": LOAD_STAGES['all'], + "mmap": False + }, '2dseq': { "parameter_files": ['visu_pars'], "property_files": [ @@ -77,6 +86,15 @@ "AdjStatePerScan": "./AdjStatePerScan", "AdjStatePerStudy": "../AdjStatePerStudy" }, + "fid_proc": { + "method": "../../method", + "acqp": "../../acqp", + "subject": "../subject", + "reco": "./reco", + "visu_pars": "./visu_pars", + "AdjStatePerScan": "../../AdjStatePerScan", + "AdjStatePerStudy": "../../../AdjStatePerStudy" + }, "2dseq": { "method": "../../method", "acqp": "../../acqp", @@ -156,7 +174,7 @@ def __init__(self, path, **state): containing it. It is possible, to create an empty object using the load switch. :param path: **str** path to dataset - :raise: :UnsuportedDatasetType: In case `Dataset.type` is not in SUPPORTED + :raise: :UnsupportedDatasetType: In case `Dataset.type` is not in SUPPORTED :raise: :IncompleteDataset: If any of the JCAMP-DX files, necessary to create a Dataset instance is missing """ @@ -170,6 +188,7 @@ def __init__(self, path, **state): content = os.listdir(self.path) if 'fid' in content: self.path = self.path / 'fid' + # TODO define correct path structure for fid_proc and rawdata? elif '2dseq' in content: self.path = self.path / '2dseq' else: @@ -246,8 +265,11 @@ def _validate(self): # Check whether all necessary JCAMP-DX files are present if self._state.get('load') >= LOAD_STAGES['parameters']: - if not (set(DEFAULT_STATES[self.type]['parameter_files']) <= set(os.listdir(str(self.path.parent)))): - raise IncompleteDataset + for i in DEFAULT_STATES[self.type]['parameter_files']: + param_path = self.path.parent / RELATIVE_PATHS[self.type][i] + if i not in set(os.listdir(str(param_path.parent))): + raise IncompleteDataset + def load(self): """ @@ -376,7 +398,8 @@ def load_properties(self): def unload_properties(self): for property in self._properties: - delattr(self,property) + if hasattr(self, property): + delattr(self,property) self._properties = [] self._state['load_properties'] = False @@ -479,7 +502,7 @@ def load_schema(self): """ Load the schema for given data set. """ - if self.type == 'fid': + if self.type in ['fid', 'fid_proc']: self._schema = SchemaFid(self) elif self.type == '2dseq': self._schema = Schema2dseq(self) diff --git a/brukerapi/schemas.py b/brukerapi/schemas.py index e2af9c7..1aa0597 100644 --- a/brukerapi/schemas.py +++ b/brukerapi/schemas.py @@ -29,6 +29,20 @@ "shape_storage", "dim_type" ], + "fid_proc": [ + "numpy_dtype", + "channels", + "block_size", + "acq_lenght", + "scheme_id", + "block_count", + "encoding_space", + "permute", + "k_space", + "encoded_dim", + "shape_storage", + "dim_type" + ], "2dseq": [ "pv_version", "numpy_dtype", From 6d4399a25f375c8ce9ada0f6d3324a5ad5713ab1 Mon Sep 17 00:00:00 2001 From: Vasilis Karlaftis Date: Tue, 3 Feb 2026 15:55:52 +0000 Subject: [PATCH 2/3] [skip ci] relaxed file size check code --- brukerapi/dataset.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/brukerapi/dataset.py b/brukerapi/dataset.py index 5f10009..73418f5 100644 --- a/brukerapi/dataset.py +++ b/brukerapi/dataset.py @@ -48,10 +48,7 @@ }, '2dseq': { "parameter_files": ['visu_pars'], - "property_files": [ - Path(__file__).parents[0] / 'config/properties_2dseq_core.json', - Path(__file__).parents[0] / 'config/properties_2dseq_custom.json' - ], + "property_files": [Path(__file__).parents[0] / 'config/properties_2dseq_core.json', Path(__file__).parents[0] / 'config/properties_2dseq_custom.json'], "load": LOAD_STAGES['all'], "scale": True, "mmap": False, @@ -570,10 +567,9 @@ def _read_binary_file(self, path, dtype, shape): """ # TODO debug with this try: - assert os.stat(str(path)).st_size == np.prod(shape) * dtype.itemsize + assert os.stat(str(path)).st_size >= np.prod(shape) * dtype.itemsize except AssertionError: raise ValueError("Dimension mismatch") from AssertionError - return np.array(np.memmap(path, dtype=dtype, shape=shape, order="F")[:]) def _write_data(self, path): From 3ab6e1348bd675da1d0047f7a063a0a9d9e4bd29 Mon Sep 17 00:00:00 2001 From: Vasilis Karlaftis Date: Thu, 12 Feb 2026 14:20:19 +0000 Subject: [PATCH 3/3] bug fix on subject file for fid_proc --- brukerapi/dataset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/brukerapi/dataset.py b/brukerapi/dataset.py index 73418f5..8b3d9f2 100644 --- a/brukerapi/dataset.py +++ b/brukerapi/dataset.py @@ -86,7 +86,7 @@ "fid_proc": { "method": "../../method", "acqp": "../../acqp", - "subject": "../subject", + "subject": "../../../subject", "reco": "./reco", "visu_pars": "./visu_pars", "AdjStatePerScan": "../../AdjStatePerScan",