Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add File organization and DICOM to NIfTI conversion sections #3

Merged
merged 49 commits into from
Sep 5, 2024

Conversation

valosekj
Copy link
Member

@valosekj valosekj commented Aug 16, 2024

This PR:

Related: #1

@valosekj

This comment was marked as resolved.

@valosekj
Copy link
Member Author

valosekj commented Aug 22, 2024

I drafted a script for the DICOM to NIfTI (BIDS) conversion in my latest commits.

The script can be run by:

python ~/code/balgrist-sci/file_loader.py \
-dicom-folder ~/data/experiments/balgrist-sci/source_data/dir_20231010 \
-bids-folder ~/data/experiments/balgrist-sci/bids \ 
-participant sub-001 \
-session ses-01 \
-contrasts T2w dwi

Then, the script prints info to the user and starts the dcm2nii conversion:

----------------------------------------------------------------------------------------------------
Dicom folder: /Users/valosek/data/experiments/balgrist-sci/source_data/dir_20231010
BIDS folder: /Users/valosek/data/experiments/balgrist-sci/bids
Participant ID: sub-001
Session ID: ses-01
Log file will be stored in: /Users/valosek/data/experiments/balgrist-sci/bids/logs/dicom_to_nifti_sub-001_ses-01_20240904_132303.log
----------------------------------------------------------------------------------------------------

Info: Converted NIfTI images will be stored in: /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01

Info: Creating a temporary folder for NIfTI images: /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/temp_dcm2niix

Info: Starting DICOM to NIfTI conversion using dcm2niix.

Compression will be faster with 'pigz' installed http://macappstore.org/pigz/
Chris Rorden's dcm2niiX version v1.0.20230411  Clang15.0.7 ARM (64-bit MacOS)
Found 56 DICOM file(s)
...

After the dcm2nii conversion, the script prompts the user to select the images for further processing. In this case, the script asks for T2w and DWI images.

...
----------------------------------------------------------------------------------------------------
DICOM to NIfTI is done. Please review the images and select images for further processing.
----------------------------------------------------------------------------------------------------
                  File Name      Dimensions                   Pixel Size
0  t2_sag_tse_stir_5.nii.gz  896 x 896 x 15  0.36 mm x 0.36 mm x 3.00 mm
1       DWI_ZOOMit_8.nii.gz    96 x 36 x 15  0.90 mm x 0.90 mm x 5.00 mm
2  t1_sag_flair_2D_4.nii.gz  864 x 864 x 15  0.37 mm x 0.37 mm x 3.00 mm
3  t1_sag_flair_2D_3.nii.gz   864 x 864 x 8  0.37 mm x 0.37 mm x 3.00 mm
4  t2_sag_tse_stir_6.nii.gz  896 x 896 x 15  0.36 mm x 0.36 mm x 3.00 mm
5    t2_sag_tse_2D_2.nii.gz  928 x 928 x 19  0.34 mm x 0.34 mm x 3.00 mm
6     t2_tra_me_2D_7.nii.gz  512 x 512 x 30  0.35 mm x 0.35 mm x 3.30 mm

Please specify the row number of the T2w image you want to use: 5
Selected T2w image: t2_sag_tse_2D_2.nii.gz
Please specify the row number of the dwi image you want to use: 1
Selected dwi image: DWI_ZOOMit_8.nii.gz

Info: Copying /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/temp_dcm2niix/t2_sag_tse_2D_2.nii.gz to /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/anat/sub-001_ses-01_T2w.nii.gz
Info: Copying /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/temp_dcm2niix/DWI_ZOOMit_8.nii.gz to /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/dwi/sub-001_ses-01_dwi.nii.gz

Info: Removing the temporary folder /Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01/temp_dcm2niix
----------------------------------------------------------------------------------------------------
All files have been successfully converted and validated. You can find the following images in the BIDS folder:
	/Users/valosek/data/experiments/balgrist-sci/bids/sub-001/ses-01
----------------------------------------------------------------------------------------------------

The output file structure then looks like this:

valosek@macbook-pro:~/data/experiments/balgrist-sci$ tree
.
├── bids
│   └── sub-001
│       └── ses-01
│           ├── anat
│           │   ├── sub-001_ses-01_T2w.json
│           │   └── sub-001_ses-01_T2w.nii.gz
│           └── dwi
│               ├── sub-001_ses-01_dwi.bval
│               ├── sub-001_ses-01_dwi.bvec
│               ├── sub-001_ses-01_dwi.json
│               └── sub-001_ses-01_dwi.nii.gz
└── source_data
    └── dir_20231010
        ├── MRc.1.3.12.2.543543
        ├── ...
        └── SRe. 1.3.12.2.5432233

@sandrinebedard
Copy link
Member

Do you have some dicoms to test it out with?

@valosekj
Copy link
Member Author

Do you have some dicoms to test it out with?

Unfortunately not publicly available. Maybe you can pick some dicoms from duke? Or what about spine-generic dicoms? Do you know if they are publicly available somewhere?

@sandrinebedard
Copy link
Member

Unfortunately not publicly available. Maybe you can pick some dicoms from duke? Or what about spine-generic dicoms? Do you know if they are publicly available somewhere?

I don't thinl they are publicly available, they are probably not defaced, and usually dicoms contains some HIPAA identifyers (identifying data) ...

@sandrinebedard
Copy link
Member

Unfortunately not publicly available. Maybe you can pick some dicoms from duke? Or what about spine-generic dicoms? Do you know if they are publicly available somewhere?

I don't thinl they are publicly available, they are probably not defaced, and usually dicoms contains some HIPAA identifyers (identifying data) ...

I'll take something on duke

@valosekj valosekj changed the title Add 'Data structure' section Add File organization and DICOM to NIfTI conversion sections Aug 23, 2024
Copy link
Member

@sandrinebedard sandrinebedard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving!

@valosekj valosekj marked this pull request as ready for review September 5, 2024 14:57
@valosekj
Copy link
Member Author

valosekj commented Sep 5, 2024

Merging! I'll continue with the code for further analysis in a new branch.

@valosekj valosekj merged commit d16c6f1 into main Sep 5, 2024
@valosekj valosekj deleted the jv/add_data_sctucture_section branch September 5, 2024 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants