Please how can i run fMRIprep with Neurodesk ?
thanks !
Command used (and if a helper script was used, a link to the helper script or the command generated):
base) jovyan@neurodesktop-2025-02-04:~/neurodesktop-storage$ cd ~/neurodesktop-storage
ls
PNFA_bids output
(base) jovyan@neurodesktop-2025-02-04:~/neurodesktop-storage$ fmriprep ~/neurodesktop-storage/PNFA_bids ~/neurodesktop-storage/output participant --participant_label sub-1S0012 --skip_bids_validation
ERROR : Could not write info to setgroups: Permission denied
ERROR : Error while waiting event for user namespace mappings: no event received
(base) jovyan@neurodesktop-2025-02-04:~/neurodesktop-storage$ sudo /cvmfs/neurodesk.ardc.edu.au/containers/fmriprep_23.0.0_20230315/fmriprep ~/neurodesktop-storage/PNFA_bids ~/neurodesktop-storage/output participant --participant_label sub-1S0012 --skip_bids_validation
Data formatted according to a validatable standard? Please provide the output of the validator:
PASTE VALIDATOR OUTPUT HERE
Relevant log outputs (up to 20 lines):
Matplotlib created a temporary config/cache directory at /tmp/matplotlib-31qzti_e because the default path (/home/fmriprep/.config/matplotlib) is not a writable directory; it is highly recommended to set the MPLCONFIGDIR environment variable to a writable directory, in particular to speed up the import of Matplotlib and to better support multiprocessing.
You are using fMRIPrep-23.0.0, and a newer version of fMRIPrep is available: 24.1.1.
Please check out our documentation about how and when to upgrade:
https://fmriprep.readthedocs.io/en/latest/faq.html#upgrading
usage: fmriprep [-h] [--skip_bids_validation] [--participant-label PARTICIPANT_LABEL [PARTICIPANT_LABEL ...]] [-t TASK_ID] [--echo-idx ECHO_IDX] [--bids-filter-file FILE] [--anat-derivatives PATH]
[--bids-database-dir PATH] [--nprocs NPROCS] [--omp-nthreads OMP_NTHREADS] [--mem MEMORY_MB] [--low-mem] [--use-plugin FILE] [--sloppy] [--anat-only] [--boilerplate-only] [--reports-only]
[--ignore {fieldmaps,slicetiming,sbref,t2w,flair} [{fieldmaps,slicetiming,sbref,t2w,flair} ...]] [--output-spaces [OUTPUT_SPACES ...]] [--longitudinal] [--bold2t1w-init {register,header}]
[--bold2t1w-dof {6,9,12}] [--force-bbr] [--force-no-bbr] [--slice-time-ref SLICE_TIME_REF] [--dummy-scans DUMMY_SCANS] [--random-seed _RANDOM_SEED] [--output-layout {bids,legacy}]
[--me-output-echos] [--medial-surface-nan] [--project-goodvoxels] [--md-only-boilerplate] [--cifti-output [{91k,170k}]] [--use-aroma] [--aroma-melodic-dimensionality AROMA_MELODIC_DIM]
[--error-on-aroma-warnings] [--return-all-components] [--fd-spike-threshold REGRESSORS_FD_TH] [--dvars-spike-threshold REGRESSORS_DVARS_TH] [--skull-strip-template SKULL_STRIP_TEMPLATE]
[--skull-strip-fixed-seed] [--skull-strip-t1w {auto,skip,force}] [--fmap-bspline] [--fmap-no-demean] [--use-syn-sdc [{warn,error}]] [--force-syn] [--fs-license-file FILE] [--fs-subjects-dir PATH]
[--no-submm-recon] [--fs-no-reconall] [--track-carbon] [--country-code COUNTRY_CODE] [--version] [-v] [-w WORK_DIR] [--clean-workdir] [--resource-monitor] [--config-file FILE] [--write-graph]
[--stop-on-first-crash] [--notrack] [--debug {compcor,fieldmaps,pdb,all} [{compcor,fieldmaps,pdb,all} ...]]
bids_dir output_dir {participant}
fmriprep: error: Path does not exist: </home/jovyan/neurodesktop-storage/PNFA_bids>.
(base) jovyan@neurodesktop-2025-02-04:~/neurodesktop-storage$ **strong text**
Thank you @Steven for ur usual support
SORRY, okay i will follow the template
The issue I’m facing is that when I use Neurodesktop, the terminal opens for less than a second and then gets forcibly closed when I try to follow the steps for running fMRIPrep.
Dear @Oumayma - these error indicate that your neurodesktop container doesn’t have the permissions it needs to start applications. Are you running this through Docker or Podman? Are you running this on Windows / Mac / Linux? On which hardware are you running this? Is it an ARM processor by any chance?
Hi @stebo85,
Please, I’m running a script for a specific preprocessing pipeline, but I encountered an error where fMRI_nuisance_regressed.nii.gz appears to be corrupted.
How can I resolve this issue? Could this be related to FSL in NeuroDesk?
I’ve attached the complete notebook for reference.
Thanks in advance for your help!
# ------------------------------------------------------------------------------
# Step 1: Discard first five volumes of fMRI data
# ------------------------------------------------------------------------------
if os.path.exists(f"{rest_output_dir}/fMRI.nii.gz"):
print("Re-discarding first 5 volumes...")
!fslroi "{rest_output_dir}/fMRI.nii.gz" "{rest_output_dir}/fMRI_discarded.nii.gz" 5 -1
else:
print("❌ ERROR: fMRI.nii.gz not found. Skipping discarding volumes.")
# ------------------------------------------------------------------------------
# Step 2: Realignment (motion correction)
# ------------------------------------------------------------------------------
if os.path.exists(f"{rest_output_dir}/fMRI_discarded.nii.gz"):
print("Re-running realignment...")
!mcflirt -in "{rest_output_dir}/fMRI_discarded.nii.gz" -out "{rest_output_dir}/fMRI_realigned" -refvol 0 -plots
if not os.path.exists(f"{rest_output_dir}/fMRI_realigned.nii.gz"):
print("❌ ERROR: Realignment failed. Output file not created.")
else:
print("❌ ERROR: fMRI_discarded.nii.gz not found. Skipping realignment.")
# ------------------------------------------------------------------------------
# Step 3: Reorient T1-weighted image to standard space
# ------------------------------------------------------------------------------
if os.path.exists(f"{anat_output_dir}/T1w.nii.gz"):
print("Reorienting T1-weighted image...")
!fslreorient2std "{anat_output_dir}/T1w.nii.gz" "{anat_output_dir}/T1w_reoriented.nii.gz"
else:
print("❌ ERROR: T1w.nii.gz not found. Skipping reorientation.")
# ------------------------------------------------------------------------------
# Step 4: T1 Segmentation (GM/WM/CSF)
# ------------------------------------------------------------------------------
if os.path.exists(f"{anat_output_dir}/T1w_reoriented.nii.gz"):
print("Running T1 segmentation...")
!fast -B -t 1 -n 3 -H 0.1 -o "{anat_output_dir}/T1w_seg" "{anat_output_dir}/T1w_reoriented.nii.gz"
# Check segmentation output
if not os.path.exists(f"{anat_output_dir}/T1w_seg_restore.nii.gz"):
print("❌ ERROR: FAST segmentation failed.")
else:
print("❌ ERROR: T1w_reoriented.nii.gz not found. Skipping segmentation.")
# ------------------------------------------------------------------------------
# Step 5: Bias correction (using FAST output)
# ------------------------------------------------------------------------------
if os.path.exists(f"{anat_output_dir}/T1w_seg_restore.nii.gz"):
print("Running bias correction...")
!fslmaths "{anat_output_dir}/T1w_seg_restore.nii.gz" -nan "{anat_output_dir}/T1w_bias_corrected.nii.gz"
else:
print("❌ ERROR: T1w_seg_restore.nii.gz not found. Skipping bias correction.")
# ------------------------------------------------------------------------------
# Step 6: Skull-stripping
# ------------------------------------------------------------------------------
if os.path.exists(f"{anat_output_dir}/T1w_bias_corrected.nii.gz"):
print("Running skull-stripping...")
!bet "{anat_output_dir}/T1w_bias_corrected.nii.gz" "{anat_output_dir}/T1w_brain" -R
else:
print("❌ ERROR: T1w_bias_corrected.nii.gz not found. Skipping skull-stripping.")
# ------------------------------------------------------------------------------
# Step 7: Coregister fMRI to T1W
# ------------------------------------------------------------------------------
if os.path.exists(f"{rest_output_dir}/fMRI_realigned.nii.gz") and os.path.exists(f"{anat_output_dir}/T1w_brain.nii.gz"):
print("Re-running coregistration...")
!flirt -in "{rest_output_dir}/fMRI_realigned.nii.gz" -ref "{anat_output_dir}/T1w_brain.nii.gz" -out "{rest_output_dir}/fMRI_coreg" -dof 6
else:
print("❌ ERROR: Required files for coregistration missing.")
# ------------------------------------------------------------------------------
# Step 8: Nuisance regression (head motion parameters)
# ------------------------------------------------------------------------------
if os.path.exists(f"{rest_output_dir}/fMRI_coreg.nii.gz") and os.path.exists(f"{rest_output_dir}/fMRI_realigned.par"):
print("Re-running nuisance regression...")
!fsl_glm -i "{rest_output_dir}/fMRI_coreg.nii.gz" -d "{rest_output_dir}/fMRI_realigned.par" -o "{rest_output_dir}/fMRI_nuisance_regressed.nii.gz"
else:
print("❌ ERROR: Required files for nuisance regression missing.")
# ------------------------------------------------------------------------------
# Step 9: Band-pass filtering (0.008–0.1 Hz)
# ------------------------------------------------------------------------------
# Define TR (repetition time) in seconds
TR = 2.0 # Change this if your TR is different
# Calculate high-pass and low-pass sigma values
highpass_sigma = 1 / (0.008 * TR) # High-pass filter (0.008 Hz)
lowpass_sigma = 1 / (0.1 * TR) # Low-pass filter (0.1 Hz)
# Check if the input file exists
if os.path.exists(f"{rest_output_dir}/fMRI_nuisance_regressed.nii.gz"):
print("Applying band-pass filter...")
print(f"High-pass sigma: {highpass_sigma}, Low-pass sigma: {lowpass_sigma}")
# Debugging: Check the input file
print("Checking fMRI_nuisance_regressed.nii.gz...")
!fslinfo "{rest_output_dir}/fMRI_nuisance_regressed.nii.gz"
# Apply band-pass filter
!fslmaths "{rest_output_dir}/fMRI_nuisance_regressed.nii.gz" -bptf {highpass_sigma} {lowpass_sigma} "{rest_output_dir}/fMRI_bandpass.nii.gz"
# Check if the output file was created
if os.path.exists(f"{rest_output_dir}/fMRI_bandpass.nii.gz"):
print("Band-pass filtering completed successfully!")
else:
print("❌ ERROR: Band-pass filtering failed. Output file not created.")
else:
print("❌ ERROR: fMRI_nuisance_regressed.nii.gz not found. Skipping filtering.")
The error is :
Re-discarding first 5 volumes...
Re-running realignment...
Reorienting T1-weighted image...
Running T1 segmentation...
Running bias correction...
Running skull-stripping...
Re-running coregistration...
Warning: An input intended to be a single 3D volume has multiple timepoints. Input will be truncated to first volume, but this functionality is deprecated and will be removed in a future release.
Warning: An input intended to be a single 3D volume has multiple timepoints. Input will be truncated to first volume, but this functionality is deprecated and will be removed in a future release.
Final result:
0.999655 -0.018830 0.018300 13.494251
0.024085 0.935145 -0.353446 10.919045
-0.010457 0.353765 0.935276 53.492782
0.000000 0.000000 0.000000 1.000000
Re-running nuisance regression...
Applying band-pass filter...
High-pass sigma: 62.5, Low-pass sigma: 5.0
Checking fMRI_nuisance_regressed.nii.gz...
Error: short read, file may be truncated
terminate called after throwing an instance of 'NiftiIO::NiftiException'
what(): Error: short read, file may be truncated
/usr/bin/singularity: line 1: 71526 Aborted (core dumped) unshare -r apptainer "$@"
❌ ERROR: Band-pass filtering failed. Output file not created.
I cannot access the notebook you shared - if you can share it with me I can have a closer look.
From just looking at the error it seems to indicate that the fMRI_nuisance_regressed.nii.gz file hasn’t been completely written to disk in the previous step. Where are you writing these files too? Is there enough free disk space? Does this file exist after it has been written? Is the file extension correct?
Thank you so much@stebo85! You made it clearer for me,
it works too!
I can’t be thankful enough
Re-discarding first 5 volumes...
Re-running realignment...
Reorienting T1-weighted image...
Running T1 segmentation...
Running bias correction...
Running skull-stripping...
Re-running coregistration...
Warning: An input intended to be a single 3D volume has multiple timepoints. Input will be truncated to first volume, but this functionality is deprecated and will be removed in a future release.
Warning: An input intended to be a single 3D volume has multiple timepoints. Input will be truncated to first volume, but this functionality is deprecated and will be removed in a future release.
Re-running nuisance regression...
Applying band-pass filter...
High-pass sigma: 62.5, Low-pass sigma: 5.0
Checking fMRI_nuisance_regressed.nii.gz...
data_type FLOAT32
dim1 256
dim2 182
dim3 256
dim4 6
datatype 16
pixdim1 0.977000
pixdim2 1.200000
pixdim3 0.977000
pixdim4 1.666160
cal_max 0.000000
cal_min 0.000000
file_type NIFTI-1+
Band-pass filtering completed successfully!