Closed mateuszpawlik closed 2 years ago
Thanks for your excellent bug report. It seems to touch the core of BIDScoin's design, I'll look into it right away and, if solved, I will do a new point release
Thank you so much. It took me more than four hours to find the problem. I don't want to rush any changes. For the moment I solved it with explicit mapping of most sequences by their full SeriesDescription
without dynamic values.
It's a miracle this never surfaced before! I hope it is solved now, can you confirm this? I'll do my point release quickly after
I built the image with your commit 2286d71. Now I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/bidsmapper", line 33, in <module>
sys.exit(load_entry_point('bidscoin==3.7.3.dev0', 'console_scripts', 'bidsmapper')())
File "/usr/local/lib/python3.9/dist-packages/bidscoin-3.7.3.dev0-py3.9.egg/bidscoin/bidsmapper.py", line 243, in main
bidsmapper(rawfolder = args.sourcefolder,
File "/usr/local/lib/python3.9/dist-packages/bidscoin-3.7.3.dev0-py3.9.egg/bidscoin/bidsmapper.py", line 60, in bidsmapper
metasubprefix = [char for char in subprefix if char in ('^', '$', '+', '{', '}', '[', ']', '\\', '|', '(', ')')]
TypeError: 'NoneType' object is not iterable
It seems like you don't set a default value in argparse.
I see, that's due to the previous patch I made to account for users that like to use wildcards in the sub-prefix. I've now tried to catch this too (see commit 8cf5c4de628de7be406977656fae2d1a62c23f05).
Now it worked :+1: I can verify it on my original data next week. Here's the output for the example in this issue:
2022-07-01 20:55:44 - INFO |
2022-07-01 20:55:44 - INFO | -------------- START BIDSmapper ------------
2022-07-01 20:55:44 - INFO | >>> bidsmapper sourcefolder=/data/sourcedata bidsfolder=/data bidsmap=bidsmap.yaml template=/home/mpawlik/Remote/bids-misc-scripts/dicom-util/bidscoin_map.yaml plugins=[] subprefix=None sesprefix=None store=False force=False
2022-07-01 20:55:44 - INFO | No existing bidsmap file found: /usr/local/lib/python3.9/dist-packages/bidscoin-3.7.3.dev0-py3.9.egg/bidscoin/heuristics/bidsmap.yaml
2022-07-01 20:55:44 - INFO | Reading: /home/mpawlik/Remote/bids-misc-scripts/dicom-util/bidscoin_map.yaml
2022-07-01 20:55:44 - INFO | BIDScoiner version difference: /home/mpawlik/Remote/bids-misc-scripts/dicom-util/bidscoin_map.yaml was created with version 3.7.2, but this is version 3.7.3-dev. This is normally ok but check the https://bidscoin.readthedocs.io/en/latest/CHANGELOG.html
2022-07-01 20:55:48 - INFO | Adding missing DICOM>anat>T1w entity key: run
2022-07-01 20:55:48 - INFO | Adding missing DICOM>anat>T1w entity key: ce
2022-07-01 20:55:48 - INFO | Adding missing DICOM>anat>T1w entity key: rec
2022-07-01 20:55:48 - INFO | Adding missing DICOM>anat>T1w entity key: part
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: acq
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: ce
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: rec
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: dir
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: run
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: echo
2022-07-01 20:55:48 - INFO | Adding missing DICOM>func>bold entity key: part
2022-07-01 20:55:48 - INFO | Mapping: /data/sourcedata/sub-1 (subject 1/1)
2022-07-01 20:55:48 - INFO | Executing plugin: dcm2niix2bids.py -> /data/sourcedata/sub-1
2022-07-01 20:55:48 - INFO | Discovered 'anat' DICOM sample: /data/sourcedata/sub-1/001-anat-T1w_acq-XYZ/MR001.dcm
2022-07-01 20:55:48 - INFO | Discovered 'func' DICOM sample: /data/sourcedata/sub-1/002-func-bold_task-rest/MR002.dcm
2022-07-01 20:55:48 - INFO | Opening the bidseditor
QStandardPaths: error creating runtime directory '/run/user/1000' (No such file or directory)
2022-07-01 20:55:53 - INFO | User is editing /data/sourcedata/sub-1/001-anat-T1w_acq-XYZ/MR001.dcm
2022-07-01 20:56:02 - INFO | User has canceled the edit
2022-07-01 20:56:04 - INFO | User is editing /data/sourcedata/sub-1/002-func-bold_task-rest/MR002.dcm
2022-07-01 20:56:09 - INFO | User has canceled the edit
2022-07-01 20:56:12 - INFO | -------------- FINISHED! -------------------
2022-07-01 20:56:12 - INFO |
2022-07-01 20:56:12 - INFO | No BIDScoin errors or warnings were reported
2022-07-01 20:56:12 - INFO |
2022-07-01 20:56:12 - INFO | For the complete log see: /data/code/bidscoin/bidsmapper.log
NB: Files in /data/code/bidscoin may contain privacy sensitive information, e.g. pathnames in logfiles and provenance data samples
Great, I'll do a bit more testing myself, update the docs a bit and wait for the successful verification on your original data before I release v3.7.3 :-)
I'm sorry but I didn't find time to test the fix. I'll try to do it tomorrow. Update: I've started but unfortunately haven't finished. I'm sorry. I'll test it latest on Monday.
I've tested 8cf5c4d with the following map file and it works as expected.
Thanks again, it should now all work in the new release :-)
Happy to help :smiley: :+1:
Describe the bug I have a sequence with
SeriesDescription
func-bold_task-rest
and a matching run-item ruleSeriesDescription: ^func.*
. However, dynamic values from other run-items are evaluated on that sequence leading toThis of course happens if my sequence doesn't match dynamic values from other run-items, in my case
SeriesDescription: ^anat.*
I'm not sure if it happens always. My original data has many more sequences.
To reproduce Steps to reproduce the behavior:
dyn-val.json
):python3 generate_dicom.py dyn-val.json dataset/sourcedata/sub-1/
singularity exec --bind dataset/:/data bidscoin_3.7.2.sif dicomsort /data/sourcedata --subprefix sub
Expected behavior The dynamic values of only the matched run-item should be evaluated on a sequence.
Adding logger outputs on what went wrong in line https://github.com/Donders-Institute/bidscoin/blob/e7555166c148496d12afa629efb43a530e52c578/bidscoin/bids.py#L1449 could help.
Software version