After converting my data with dcm2bids, I checked my resting-state 4D image in MRIcron to see if it converted correctly, and the number of volumes it provides is less than the number of 3D files we have. Our resting-state runs should always have 375 volumes and when I checked it only had 374 volumes for RS1 and 371 volumes for RS2.
DCM directory Structure
Command used
python run_dcm2bids.py
Python script
import subprocess
# Function to run dcm2bids command
def run_dcm2bids(dicom_dir, participant, session, config_file, output_dir):
# Constructing the command
command = [
'dcm2bids', # Command to be executed
'-d', dicom_dir, # DICOM directory argument
'-p', participant, # Participant ID argument
'-s', session, # Session ID argument
'-c', config_file, # Configuration file argument
'-o', output_dir, # Output directory argument
'--auto_extract_entities',
'--force'
]
# Running the command
subprocess.run(command, check=True)
# Participant ID
participant = 'ID06'
# List of session directories for the participant and corresponding session information
sessions = [
{
'session': 's01',
'dicom_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\E6\DCM\func\sess1',
'config_file': r'C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json',
'output_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data'
},
{
'session': 's02',
'dicom_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\E6\DCM\func\sess2',
'config_file': r'C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess2.json',
'output_dir': r'C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data'
}
]
# Run dcm2bids for each session
for session_info in sessions:
run_dcm2bids(
dicom_dir=session_info['dicom_dir'],
participant=participant,
session=session_info['session'],
config_file=session_info['config_file'],
output_dir=session_info['output_dir']
)
Configuration file
{
"descriptions": [
{
"datatype": "func",
"suffix": "bold",
"custom_entities": "task-RS1",
"criteria": {
"ProtocolName": "Mb5_55slice_RS1"
},
"sidecarChanges": {
"TaskName": "task-RS1"
}
},
{
"datatype": "func",
"suffix": "bold",
"custom_entities": "task-training1",
"criteria": {
"ProtocolName": "Mb5_55slice_MSL_1"
},
"sidecarChanges": {
"TaskName": "task-training1"
}
},
{
"datatype": "func",
"suffix": "bold",
"custom_entities": "task-training2",
"criteria": {
"ProtocolName": "Mb5_55slice_MSL_2"
},
"sidecarChanges": {
"TaskName": "task-training2"
}
},
{
"datatype": "func",
"suffix": "bold",
"custom_entities": "task-test",
"criteria": {
"ProtocolName": "Mb5_55slice_MSL_TEST"
},
"sidecarChanges": {
"TaskName": "task-test"
}
},
{
"datatype": "func",
"suffix": "bold",
"custom_entities": "task-RS2",
"criteria": {
"ProtocolName": "Mb5_55slice_RS2"
},
"sidecarChanges": {
"TaskName": "task-RS2"
}
}
]
}
Version: 3.2.0
Environment (Docker, Singularity / Apptainer, custom installation):
Within Anaconda environment
Relevant log outputs (up to 20 lines):
2024-08-02 11:33:48.445 - INFO - dcm2bids.main | --- dcm2bids start ---
2024-08-02 11:33:48.446 - INFO - dcm2bids.main | Running the following command: C:\Users\u1350546\AppData\Local\anaconda3\envs\dcm2bids\Scripts\dcm2bids -d C:\Users\u1350546\Documents\Analysis_MRI_Data\E6\DCM\func\sess1 -p ID06 -s s02 -c C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json -o C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data --auto_extract_entities --force
2024-08-02 11:33:48.546 - INFO - dcm2bids.main | OS version: Windows-10-10.0.19042-SP0
2024-08-02 11:33:48.546 - INFO - dcm2bids.main | Python version: 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:56) [MSC v.1929 64 bit (AMD64)]
2024-08-02 11:33:48.546 - INFO - dcm2bids.main | dcm2bids version: 3.2.0
2024-08-02 11:33:48.629 - INFO - dcm2bids.main | dcm2niix version: v1.0.20240202
2024-08-02 11:33:48.629 - INFO - dcm2bids.main | Checking for software update
2024-08-02 11:33:49.284 - INFO - tools.check_latest | Currently using the latest version of dcm2bids.
2024-08-02 11:33:49.637 - INFO - tools.check_latest | Currently using the latest version of dcm2niix.
2024-08-02 11:33:49.637 - INFO - dcm2bids.main | participant: sub-ID06
2024-08-02 11:33:49.637 - INFO - dcm2bids.main | session: ses-s02
2024-08-02 11:33:49.646 - INFO - dcm2bids.main | config: C:\Users\u1350546\Box\Ankes documents\Lifespan Imaging Project\Data analysis\DCM2BIDS\configuration_files\dcm2bids_config_func_sess1.json
2024-08-02 11:33:49.646 - INFO - dcm2bids.main | BIDS directory: C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data
2024-08-02 11:33:49.647 - INFO - dcm2bids.main | Auto extract entities: True
2024-08-02 11:33:49.647 - INFO - dcm2bids.main | Reorder entities: True
2024-08-02 11:33:49.648 - INFO - dcm2bids.main | Validate BIDS: False
2024-08-02 11:33:49.658 - INFO - utils.run_shell_command | Running: dcm2niix -b y -ba y -z y -f %3s_%f_%p_%t -o C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02 C:\Users\u1350546\Documents\Analysis_MRI_Data\E6\DCM\func\sess1
2024-08-02 11:39:30.695 - DEBUG - dcm2niix_gen.execute |
Chris Rorden's dcm2niiX version v1.0.20240202 MSC1929 (64-bit Windows)
Found 2007 DICOM file(s)
Convert 126 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02\017_sess1_Mb5_55slice_MSL_TEST_20230217105927 (88x88x55x126)
Convert 510 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02\015_sess1_Mb5_55slice_MSL_2_20230217105927 (88x88x55x510)
Convert 371 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02\019_sess1_Mb5_55slice_RS2_20230217105927 (88x88x55x371)
Convert 374 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02\011_sess1_Mb5_55slice_RS1_20230217105927 (88x88x55x374)
Convert 626 DICOM as C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\sub-ID06_ses-s02\013_sess1_Mb5_55slice_MSL_1_20230217105927 (88x88x55x626)
Conversion required 341.002014 seconds.
2024-08-02 11:39:30.696 - INFO - dcm2niix_gen.execute | Check log file for dcm2niix output
2024-08-02 11:39:30.703 - INFO - sidecar.build_acquisitions | SIDECAR PAIRING
2024-08-02 11:39:30.705 - INFO - sidecar.build_acquisitions | sub-ID06_ses-s02_task-RS1_bold <- 011_sess1_Mb5_55slice_RS1_20230217105927
2024-08-02 11:39:30.705 - INFO - sidecar.build_acquisitions | sub-ID06_ses-s02_task-training1_bold <- 013_sess1_Mb5_55slice_MSL_1_20230217105927
2024-08-02 11:39:30.706 - INFO - sidecar.build_acquisitions | sub-ID06_ses-s02_task-training2_bold <- 015_sess1_Mb5_55slice_MSL_2_20230217105927
2024-08-02 11:39:30.706 - INFO - sidecar.build_acquisitions | sub-ID06_ses-s02_task-test_bold <- 017_sess1_Mb5_55slice_MSL_TEST_20230217105927
2024-08-02 11:39:30.707 - INFO - sidecar.build_acquisitions | sub-ID06_ses-s02_task-RS2_bold <- 019_sess1_Mb5_55slice_RS2_20230217105927
2024-08-02 11:39:30.708 - INFO - dcm2bids_gen.run | Moving acquisitions into BIDS folder "C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\sub-ID06\ses-s02".
2024-08-02 11:39:38.62 - INFO - dcm2bids.main | Logs saved in C:\Users\u1350546\Documents\Analysis_MRI_Data\BIDS_data\tmp_dcm2bids\log\sub-ID06_ses-s02_20240802-113348.log
2024-08-02 11:39:38.62 - INFO - dcm2bids.main | --- dcm2bids end ---