On Sep 30, 2024, at 7:16 AM, Camilo Castelblanco Riveros <camilo.a.castelblanco.riveros.gr@dartmouth.edu> wrote:
External Email - Use Caution
_______________________________________________Hi,
I am trying to print screenshots of MR images efficiently with the freesurfer reconstruction with Freeview in an HPC. For an unknown reason, this code works for iterating over sagittal, not coronal or axial coordinates. It does not iterate over the coordinates in the coronal and axial cases even though the cmd file looks okay.Any help would be appreciated.
--------# Define the MRI and surface files for the current subjectT1_IMAGE="${SUBJECT_DIR}/mri/T1.mgz"WM_IMAGE="${SUBJECT_DIR}/mri/wm.mgz"BRAINMASK_IMAGE="${SUBJECT_DIR}/mri/brainmask.mgz"ASEG_IMAGE="${SUBJECT_DIR}/mri/aseg.mgz"LH_WHITE="${SUBJECT_DIR}/surf/lh.white"LH_PIAL="${SUBJECT_DIR}/surf/lh.pial"RH_WHITE="${SUBJECT_DIR}/surf/rh.white"RH_PIAL="${SUBJECT_DIR}/surf/rh.pial"
# Define number of slices and step size for each view (sagittal, coronal, axial)STEPS=15 # Increase this value for more plots/slicesSAGITTAL_START=20SAGITTAL_END=200CORONAL_START=20CORONAL_END=200AXIAL_START=20AXIAL_END=200
# Create a fresh cmd.txt file for the current subjectecho "-v $T1_IMAGE \$WM_IMAGE \$BRAINMASK_IMAGE \$ASEG_IMAGE:colormap=lut:opacity=0.2" > "$CMD_FILE"echo "-f $LH_WHITE:edgecolor=blue \$LH_PIAL:edgecolor=red \$RH_WHITE:edgecolor=blue \$RH_PIAL:edgecolor=red" >> "$CMD_FILE"
# Loop through slices in each dimension and add commands to cmd.txt
#==================> Sagittal view slices (changes in X-coordinate)for ((i = 0; i <= STEPS; i++)); doslice=$(bc <<< "$SAGITTAL_START + ($SAGITTAL_END - $SAGITTAL_START) * $i / $STEPS")echo "-viewport sagittal -slice $slice 127 127 -viewsize 800 800 -ss ${OUTPUT_DIR}/sagittal_slice_${slice}.png -noquit" >> "$CMD_FILE"done
# Reset the view and Freeview instance to avoid cache issues between viewsecho "-quit" >> "$CMD_FILE"echo "Processing sagittal slices..." # Debug message
freeview -cmd "$CMD_FILE" > freeview_log.txt 2>&1sleep 2 # Wait for Freeview to close completely
# If Freeview doesn't quit properly, use pkill as a fallbackpkill freeview
#%%%%%%%%%%%%%%%%%%%%
# Create a fresh cmd.txt for coronal slicesCMD_FILE="${OUTPUT_DIR}/cmd_coronal.txt"
#================> Coronal view slices (changes in Y-coordinate)for ((i = 0; i <= STEPS; i++)); doslice=$(bc <<< "$CORONAL_START + ($CORONAL_END - $CORONAL_START) * $i / $STEPS")echo "-viewport coronal -slice 127 $slice 127 -viewsize 800 800 -ss ${OUTPUT_DIR}/coronal_slice_${slice}.png -noquit" >> "$CMD_FILE"done
-------Best regards,Camilo
================================
Camilo Castelblanco Riveros (He/His)Integrative Neuroscience at Dartmouth (IND) Ph.D. CandidateStudent Interest Group in Neurology (SIGN) Co-LeaderDiversity Student Advisory Board Member
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer