Skip to content

Commit

Permalink
Avoid using pydicom 3 (for now), as it seems to cause random test fai…
Browse files Browse the repository at this point in the history
…lures
  • Loading branch information
marcelzwiers committed Sep 24, 2024
1 parent 7f47f17 commit 2e6122b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
9 changes: 8 additions & 1 deletion bidscoin/bids.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ def get_matching_run(self, datasource: DataSource, runtime=False) -> Tuple[RunIt

unknowndatatypes = self.options.get('unknowntypes') or ['unknown_data']
ignoredatatypes = self.options.get('ignoretypes') or []
bidsdatatypes = sorted([dtype.datatype for dtype in self.dataformat(datasource.dataformat).datatypes if dtype not in unknowndatatypes + ignoredatatypes])
bidsdatatypes = [dtype.datatype for dtype in self.dataformat(datasource.dataformat).datatypes if dtype not in unknowndatatypes + ignoredatatypes]
datasource = copy.deepcopy(datasource)
rundata = {'provenance': str(datasource.path), 'properties': {}, 'attributes': {}, 'bids': {}, 'meta': {}}
"""The a run-item data structure. NB: Keep in sync with the RunItem() data attributes"""
Expand Down Expand Up @@ -1457,6 +1457,13 @@ def delete_run(self, provenance: Union[RunItem, str], datatype: Union[str, DataT
dtype = dformat.datatype(str(datatype) or runitem.datatype)
dtype.delete_run(provenance)

def delete_runs(self):
"""Delete all run-items from the bidsmap"""

for dataformat in self.dataformats:
for datatype in dataformat.datatypes:
dataformat.delete_runs(datatype)

def insert_run(self, runitem: RunItem, position: int=None):
"""
Inserts a run-item (as is) to the BIDS map (e.g. allowing you to insert a run-item from another bidsmap).
Expand Down
4 changes: 1 addition & 3 deletions bidscoin/bidseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ def __init__(self, bidsfolder: Path, input_bidsmap: BidsMap, template_bidsmap: B
template_bidsmap.plugins = input_bidsmap.plugins # Always use the plugins of the input bidsmap
else:
input_bidsmap = copy.deepcopy(template_bidsmap)
for dataformat in input_bidsmap.dataformats:
for datatype in dataformat.datatypes:
dataformat.delete_runs(datatype)
input_bidsmap.delete_runs()

# Keep track of the EditWindow status
self.editwindow_opened: Union[str,None] = None
Expand Down
4 changes: 1 addition & 3 deletions bidscoin/bidsmapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,7 @@ def bidsmapper(sourcefolder: str, bidsfolder: str, bidsmap: str, template: str,
bidsmap_new.options['unzip'] = unzip
else:
unzip = bidsmap_new.options.get('unzip','')
for dataformat in bidsmap_new.dataformats:
for datatype in dataformat.datatypes:
dataformat.delete_runs(datatype)
bidsmap_new.delete_runs()

# Store/retrieve the empty or user-defined sub-/ses-prefix. The new bidsmap is now ready to be populated
subprefix, sesprefix = setprefix(bidsmap_new, subprefix, sesprefix, rawfolder, update = not no_update)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = ['Programming Language :: Python :: 3.8',
dependencies = ['pandas',
'matplotlib',
'numpy',
'pydicom >= 2',
'pydicom >= 2, < 3',
'PyQt6',
'ruamel-yaml > 0.17.2',
'tomli >= 1.1.0 ; python_version < "3.11"',
Expand Down

0 comments on commit 2e6122b

Please sign in to comment.