Donders-Institute / bidscoin

BIDScoin converts your source-level neuroimaging data to BIDS
https://bidscoin.readthedocs.io
GNU General Public License v3.0
131 stars 35 forks source link

bidscoiner v4.4.0: AttributeError: 'NoneType' object has no attribute 'provenance' #241

Closed maxlaansma closed 1 month ago

maxlaansma commented 1 month ago

Dear support team,

Would you have time to help with the following? I created this bidsmap.yaml with bidseditor to process PAR/REC files (with dcm2niix2bids) and NIFTI files (with nibabel2bids) altogether. The sourcedata files ar stored in one folder. When running bidscoiner version 4.4.0 as below, it confirms that the run-items in the bidsmap are valid, but then dcm2niix2bids does not seem to recognize the PAR file format and skips the run. Finally it exits with the AttributeError, relating to the provenance. I double checked that all paths are valid and files are in place.

Thank you in advance!

Max bidsmap.yaml.txt

(nipoppy_env) slurm luna-02:585382> bidscoiner /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/sourcedata /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids -p sub-REM033 -b /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids/code/bidscoin/bidsmap.yaml

INFO | INFO | -------------- START BIDScoiner 4.4.0: BIDS 1.10.0 ------------ INFO | >>> bidscoiner sourcefolder=/scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/sourcedata bidsfolder=/scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids participant=['sub-REM033'] force=False bidsmap=/scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids/code/bidscoin/bidsmap.yaml INFO | Reading: /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids/code/bidscoin/bidsmap.yaml INFO | Checking the bidsmap run-items: SUCCESS | All run-items in the bidsmap are valid INFO | ------------------- Subject 1/1 ------------------- INFO | >>> Coining datasources in: /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/sourcedata/sub-REM033/ses-1 WARNING | Existing BIDS output-directory found, which may result in duplicate data (with increased run-index). Make sure /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids/sub-REM033/ses-1 was cleaned-up from old data before (re)running the bidscoiner VERBOSE | Executing plugin: dcm2niix2bids ERROR | --> Skipping unknown run: [PAR] /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/sourcedata/sub-REM033/ses-1/sub-REM033_B0_unshimmed_small_3_1.PAR -> Re-run the bidsmapper and delete /scratch/anw/malaansma/REMIND/nipoppy/nipoppy/REMIND/bids/sub-REM033/ses-1 to solve this warning Traceback (most recent call last): File "/home/anw/malaansma/.conda/envs/nipoppy_env/bin/bidscoiner", line 8, in <module> sys.exit(main()) File "/home/anw/malaansma/.conda/envs/nipoppy_env/lib/python3.9/site-packages/bidscoin/bidscoiner.py", line 324, in main raise error File "/home/anw/malaansma/.conda/envs/nipoppy_env/lib/python3.9/site-packages/bidscoin/bidscoiner.py", line 320, in main bidscoiner(**vars(args)) File "/home/anw/malaansma/.conda/envs/nipoppy_env/lib/python3.9/site-packages/bidscoin/bidscoiner.py", line 288, in bidscoiner personals = module.bidscoiner_plugin(sesfolder, bidsmap, bidssession) File "/home/anw/malaansma/.bidscoin/4.4.0/plugins/dcm2niix2bids.py", line 265, in bidscoiner_plugin bids.bidsprov(bidsses, source) # Write out empty provenance logging data File "/home/anw/malaansma/.conda/envs/nipoppy_env/lib/python3.9/site-packages/bidscoin/bids.py", line 2726, in bidsprov provdata.loc[str(source)] = [runitem.provenance, runitem.datatype or 'n/a', ', '.join([f"{target.parts[1]+':' if target.parts[0]=='derivatives' else ''}{target.name}" for target in targets])] AttributeError: 'NoneType' object has no attribute 'provenance'

espentrydal commented 1 month ago

Not a part of the bidscoiner team, but I got this problem and it seems that the most recent version (4.4.0) don't have the "provenance" field in the template (contrary to 4.3). You can check the difference in the default templates between the two versions. Removing the provenance lines solved the problem for me.

marcelzwiers commented 1 month ago

Sorry for responding so late, I was busy with something else. In 4.4 I did a significant refactoring, and it seems that this bug slipped through. I removed the provenance item from the template bidsmap, because it is only used in the study bidsmap. In my tests I didn't have your error:

 ERROR | --> Skipping unknown run

Which is evoking this provenance bug. I will fix this in the next release, but in the meantime, you should make sure to solve the errors (and warnings) printed by BIDScoin (as above), then I believe you won't get this issue

marcelzwiers commented 1 month ago

I suggest you start with a new bids output directory, run the bidsmapper and then the bidscoiner. Let me know if you get any warnings or errors that you can't solve, and re-open this issue if needed