Thanks again for a great tool!
I am trying to convert a large par/rec dataset into bids format. Going well for the most part, but for some particular files something goes wrong with the conversion.
Context:
Using bidsify in a Jupyter Notebook under Windows in Anaconda environment. I have one task in which the scans were manually stopped. For the most part conversion goes well, with output like this:
Converting data from sub-BTP3089 ... (ses-02)
Found 166.263 vols (6318 slices) for file BT2P3089_5_1_task_feedback.PAR, but expected 240 dyns (9120 slices); going to try to fix it by removing slices from the PAR header ...
Found 148.237 vols (5633 slices) for file BT2P3089_6_1_task_feedback.PAR, but expected 210 dyns (7980 slices); going to try to fix it by removing slices from the PAR header ...
Renaming 'F:\bt_tasks\bids\sub-BTP3089\ses-02\BT2P3089_5_1_task_feedback.json' to 'F:\bt_tasks\bids\sub-BTP3089\ses-02\func\sub-BTP3089_ses-02_task-feedback_run-1_bold.json'
Renaming 'F:\bt_tasks\bids\sub-BTP3089\ses-02\BT2P3089_5_1_task_feedback.nii' to 'F:\bt_tasks\bids\sub-BTP3089\ses-02\func\sub-BTP3089_ses-02_task-feedback_run-1_bold.nii'
Error:
But for some particular files I get the following error (and these files are not converted to nifti):
Converting data from sub-BTP1574 ... (ses-01)
Found 164.000 vols (6232 slices) for file BT1P1574_5_1_task_feedback.PAR, but expected 240 dyns (9120 slices); going to try to fix it by removing slices from the PAR header ...
INFO: Could not find files for the given pattern(s).
INFO: Could not find files for the given pattern(s).
c:\programdata\anaconda3\lib\site-packages\bidsify\main.py:371: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
cfg = yaml.load(config)
Traceback (most recent call last):
File "c:\programdata\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "c:\programdata\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\Scripts\bidsify.exe__main__.py", line 9, in
File "c:\programdata\anaconda3\lib\site-packages\bidsify\main.py", line 127, in run_cmd
out_dir=args.out, validate=args.validate)
File "c:\programdata\anaconda3\lib\site-packages\bidsify\main.py", line 192, in bidsify
_process_directory(sub_dir, out_dir, cfg, is_sess=False)
File "c:\programdata\anaconda3\lib\site-packages\bidsify\main.py", line 258, in _process_directory
_process_directory(sess_dir, out_dir, cfg, is_sess=True)
File "c:\programdata\anaconda3\lib\site-packages\bidsify\main.py", line 290, in _process_directory
convert_mri(this_out_dir, cfg)
File "c:\programdata\anaconda3\lib\site-packages\bidsify\mri2nifti.py", line 28, in convert_mri
_fix_header_manually_stopped_scan(f)
File "c:\programdata\anaconda3\lib\site-packages\bidsify\mri2nifti.py", line 178, in _fix_header_manually_stopped_scan
str(int(actual_n_dyns)))
UnboundLocalError: local variable 'actual_n_dyns' referenced before assignment
Question:
I have tried to simply rerun these particular runs/tasks but they keep failing. Do you think this is an issue with the particular file? Or might there be something else that causes the UnboundLocalError?
Note that I also tested whether conversion using dcm2niix without bidsify works for these files and that works. So it seems to be a bidsify specific issue.
Hi Lukas,
Thanks again for a great tool! I am trying to convert a large par/rec dataset into bids format. Going well for the most part, but for some particular files something goes wrong with the conversion.
Context: Using bidsify in a Jupyter Notebook under Windows in Anaconda environment. I have one task in which the scans were manually stopped. For the most part conversion goes well, with output like this:
Error: But for some particular files I get the following error (and these files are not converted to nifti):
Question: I have tried to simply rerun these particular runs/tasks but they keep failing. Do you think this is an issue with the particular file? Or might there be something else that causes the UnboundLocalError?
Note that I also tested whether conversion using dcm2niix without bidsify works for these files and that works. So it seems to be a bidsify specific issue.
Best, Eduard