ivadomed / model_seg_sci

Deep-learning based segmentation of the spinal cord and intramedually lesions in traumatic and non-traumatic SCI
MIT License
12 stars 2 forks source link

Add script/instructions to convert DICOM data to BIDS #3

Open jcohenadad opened 3 years ago

jcohenadad commented 3 years ago

The Stanford site needs a script with instructions to convert their data to BIDS format. I suggest using dcm2bids and add the custom JSON config file in this repository.

In terms of organization, I suggest creating a bids_conversion/ folder, with all JSON files enclosed and a README.md file with instructions.

The first step would be for @alexfoias to get in touch with the Stanford group to understand how their DICOM data are organized.

kennethaweberii commented 3 years ago

@andrewsm8 can you provide @alexfoias with a description of how your DICOM data are organized.

andrewsm8 commented 3 years ago

Hello @kennethaweberii and @alexfoias,

I have the axial T2-weighted images organized as follows:

AxialDICOMs Project folder -> Each participant has a subfolder labeled using their 4-digit code -> ~30 axial DICOMs for each participant.

I can certainly organize in a different manner if necessary.

jcohenadad commented 3 years ago

@alexfoias is currently on vacation, coming back in September 6th, and he will contact you right away to get this done

alexfoias commented 3 years ago

@jcohenadad I have contacted @andrewsm8 by email for more details since we are dealing with confidential information.

andrewsm8 commented 3 years ago

@jcohenadad I have contacted @andrewsm8 by email for more details since we are dealing with confidential information.

Hello @alexfoias, I met with @kennethaweberii and we successfully installed dcm2bids. Within a Conda environment, the following to activate that environment:

source activate dcm2bids.

We then ran the following:

python curate_bids_ucd.py -i /Users/asmith034/desktop/R03/data -o OUTPUT_PATH -c config_file_ucd.txt

It appears the script gives us the .json files and .tsv, but it is not converting the DICOM files into NIFTI. We get the following error message:

INFO:dcm2bids.dcm2bids:--- dcm2bids start --- INFO:dcm2bids.dcm2bids:OS:version: macOS-11.6-x86_64-i386-64bit INFO:dcm2bids.dcm2bids:python:version: 3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:31:23) [Clang 11.1.0 ] INFO:dcm2bids.dcm2bids:dcm2bids:version: 2.1.6 INFO:dcm2bids.dcm2bids:dcm2niix:version: v1.0.20210317 INFO:dcm2bids.dcm2bids:participant: sub-5493 INFO:dcm2bids.dcm2bids:session: INFO:dcm2bids.dcm2bids:config: /Users/asmith034/Desktop/dcm2bids-tutorial/config_file_ucd.txt INFO:dcm2bids.dcm2bids:BIDS directory: /Users/asmith034/Desktop/dcm2bids-tutorial/OUTPUTPATH INFO:dcm2bids.utils:Running dcm2niix -b y -ba y -z y -f '%3s%f%p%t' -o OUTPUT_PATH/tmp_dcm2bids/sub-5493 /Users/asmith034/desktop/R03/data/5493 Traceback (most recent call last): File "/opt/anaconda3/envs/dcm2bids/bin/dcm2bids", line 10, in sys.exit(main()) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 291, in main return app.run() File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 120, in run dcm2niix.run(self.forceDcm2niix) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2niix.py", line 90, in run self.execute() File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2niix.py", line 100, in execute output = run_shell_command(cmd) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/utils.py", line 113, in run_shell_command return check_output(shlex.split(commandLine)) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/subprocess.py", line 424, in checkoutput return run(*popenargs, stdout=PIPE, timeout=timeout, check=True, File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['dcm2niix', '-b', 'y', '-ba', 'y', '-z', 'y', '-f', '%3s%f%p%t', '-o', 'OUTPUT_PATH/tmp_dcm2bids/sub-5493', '/Users/asmith034/desktop/R03/data/5493']' returned non-zero exit status 2. Traceback (most recent call last): File "/opt/anaconda3/envs/dcm2bids/bin/dcm2bids", line 10, in sys.exit(main()) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 290, in main app = Dcm2bids(*vars(args)) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 49, in init self.dicomDirs = dicom_dir File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 90, in dicomDirs raise FileNotFoundError(dir_not_found) FileNotFoundError: ['/Users/asmith034/desktop/R03/data/.DS_Store'] INFO:dcm2bids.dcm2bids:--- dcm2bids start --- INFO:dcm2bids.dcm2bids:OS:version: macOS-11.6-x86_64-i386-64bit INFO:dcm2bids.dcm2bids:python:version: 3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:31:23) [Clang 11.1.0 ] INFO:dcm2bids.dcm2bids:dcm2bids:version: 2.1.6 INFO:dcm2bids.dcm2bids:dcm2niix:version: v1.0.20210317 INFO:dcm2bids.dcm2bids:participant: sub-5416 INFO:dcm2bids.dcm2bids:session: INFO:dcm2bids.dcm2bids:config: /Users/asmith034/Desktop/dcm2bids-tutorial/config_file_ucd.txt INFO:dcm2bids.dcm2bids:BIDS directory: /Users/asmith034/Desktop/dcm2bids-tutorial/OUTPUTPATH INFO:dcm2bids.utils:Running dcm2niix -b y -ba y -z y -f '%3s%f%p%t' -o OUTPUT_PATH/tmp_dcm2bids/sub-5416 /Users/asmith034/desktop/R03/data/5416 Traceback (most recent call last): File "/opt/anaconda3/envs/dcm2bids/bin/dcm2bids", line 10, in sys.exit(main()) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 291, in main return app.run() File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2bids.py", line 120, in run dcm2niix.run(self.forceDcm2niix) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2niix.py", line 90, in run self.execute() File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/dcm2niix.py", line 100, in execute output = run_shell_command(cmd) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/site-packages/dcm2bids/utils.py", line 113, in run_shell_command return check_output(shlex.split(commandLine)) File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/subprocess.py", line 424, in check_output return run(popenargs, stdout=PIPE, timeout=timeout, check=True, File "/opt/anaconda3/envs/dcm2bids/lib/python3.9/subprocess.py", line 528, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['dcm2niix', '-b', 'y', '-ba', 'y', '-z', 'y', '-f', '%3s%f%p_%t', '-o', 'OUTPUT_PATH/tmp_dcm2bids/sub-5416', '/Users/asmith034/desktop/R03/data/5416']' returned non-zero exit status 2. []

alexfoias commented 3 years ago

Hi @andrewsm8 ,

I had that type of issue in the past. Please see here: https://github.com/UNFmontreal/Dcm2Bids/issues/139

I will right down a procedure on the PR so you can have all the dependencies properly configure.

Could you please let me know what OS are you using ? Thank you.

andrewsm8 commented 3 years ago

@alexfoias, @kennethaweberii, yes I am using macOS Big Sur Version 11.6. Thank you!

alexfoias commented 3 years ago

Okay. Perfect. I will reach back to you with more details.

alexfoias commented 3 years ago

@andrewsm8 I have added some instructions on the PR. Please check them out. If you still have issues, please feel free to contact me.

jcohenadad commented 3 years ago

@andrewsm8 I have added some instructions on the PR. Please check them out. If you still have issues, please feel free to contact me.

@alexfoias could you please cross-reference the PR you are referring to?

alexfoias commented 3 years ago

Yes, I have added the link to the latest comment on the PR.

kennethaweberii commented 2 years ago

@jcohenadad @alexfoias We are exporting our spinal cord and lesion segmentations for our axial T2w images. Should the spinal cord segmentation contain the lesion segmentation? In other words, should the lesioned tissue be considered as part of the spinal cord? Thanks, Ken

jcohenadad commented 2 years ago

@jcohenadad @alexfoias We are exporting our spinal cord and lesion segmentations for our axial T2w images. Should the spinal cord segmentation contain the lesion segmentation? In other words, should the lesioned tissue be considered as part of the spinal cord? Thanks, Ken

yes