andersonwinkler / PALM

PALM: Permutation Analysis of Linear Models
70 stars 28 forks source link

Error using save_gii; Function is not defined for 'cell' inputs. #61

Closed psadil closed 2 weeks ago

psadil commented 1 month ago

I am running into an error while trying to follow along with Example 10: Using CiFTi files . I apologize if I'm just not setting up the command correctly.

LIST_SUBJECTS=(147737 165840 172332 192237)

# gather files
root=/dcs07/smart/data/human-connectome-project-openaccess/HCP
for s in "${LIST_SUBJECTS[@]}" ; do
    cp ${root}/"${s}"/MNINonLinear/Results/tfMRI_MOTOR/tfMRI_MOTOR_hp200_s4_level2_MSMAll.feat/GrayordinatesStats/cope1.feat/cope1.dtseries.nii "${s}"_cope1.dtseries.nii
    cp ${root}/"${s}"/MNINonLinear/fsaverage_LR32k/"${s}".L.midthickness_MSMAll.32k_fs_LR.surf.gii ./
done

wb_shortcuts -cifti-concatenate merged.dtseries.nii 147737_cope1.dtseries.nii 165840_cope1.dtseries.nii 172332_cope1.dtseries.nii 192237_cope1.dtseries.nii
wb_command -cifti-separate merged.dtseries.nii COLUMN -volume-all data_sub.nii -metric CORTEX_LEFT data_L.func.gii -metric CORTEX_RIGHT data_R.func.gii

for s in "${LIST_SUBJECTS[@]}" ; do
    wb_command -surface-vertex-areas "${s}".L.midthickness_MSMAll.32k_fs_LR.surf.gii "${s}".L_midthick_va.shape.gii
done

L_MERGELIST=""
for s in "${LIST_SUBJECTS[@]}" ; do
    L_MERGELIST="${L_MERGELIST} -metric ${s}.L_midthick_va.shape.gii"
done

wb_command -metric-merge L_midthick_va.func.gii ${L_MERGELIST}
wb_command -metric-reduce L_midthick_va.func.gii MEAN L_area.func.gii

L_MERGELIST=""
for s in "${LIST_SUBJECTS[@]}" ; do
   L_MERGELIST="${L_MERGELIST} -surf ${s}.L.midthickness_MSMAll.32k_fs_LR.surf.gii"
done

wb_command -surface-average L_midthickness.surf.gii ${L_MERGELIST}

# this runs fine
palm -i data_sub.nii -o results_sub -T -logp -ise

# but this throws an error
palm -i data_L.func.gii -o results_L_cort -T -tfce2D -s L_midthickness.surf.gii L_area.func.gii -logp -ise
Running PALM (github)
 using MATLAB 23.2.0.2428915 (R2023b) Update 4 with the following options:
-i data_L.func.gii
-o results_L_cort
-T
-tfce2D
-s L_midthickness.surf.gii L_area.func.gii
-logp
-ise
PALM is located at /fastscratch/myscratch/pssadil/PALM
Found FSL in /jhpce/shared/jhpce/core/fsl/6.0.6.5/
Found HCP Workbench executable in ~/workbench/bin_rh_linux64/wb_command
Loading surface 1/1: L_midthickness.surf.gii
Reading input 1/1: data_L.func.gii
Reading design matrix and contrasts.
Elapsed time parsing inputs: ~ 6.37366 seconds.
Number of possible sign-flips is 16 = 2^4.
Generating 16 shufflings (sign-flips only).
Building null distribution.
3.12%    [Design 1/1, Contrast 1/2, Shuffling 1/16, Modality 1/1]
     Saving file: results_L_cort_dpv_tstat_c1
Error using save_gii (/fastscratch/myscratch/pssadil/PALM/fileio/@gifti/save.m:191)
Function is not defined for 'cell' inputs.

Error in save (/fastscratch/myscratch/pssadil/PALM/fileio/@gifti/save.m:43->save_gii)
Error in palm_miscwrite (/fastscratch/myscratch/pssadil/PALM/palm_miscwrite.m:232->save)
Error in palm_quicksave (/fastscratch/myscratch/pssadil/PALM/palm_quicksave.m:163->palm_miscwrite)
Error in palm_core (/fastscratch/myscratch/pssadil/PALM/palm_core.m:1549->palm_quicksave)
Error in palm (/fastscratch/myscratch/pssadil/PALM/palm.m:81->palm_core)
$ basename $PWD
PALM
$ git rev-parse HEAD
762ba37a014247aa6b7aa3f6e4657c697905fbd6
andersonwinkler commented 3 weeks ago

Hi Patrick,

Can you verify which variable being passed to "save" in palm_miscwrite is a cell array? None should be...

Alternatively, can you send me your 3 input files (data_L, L_midthickness, and L_area). You can share from, e.g., OneDrive or Dropbox or any other service. My email is like my username here on Github, at gmail.

Thanks!

Anderson

psadil commented 3 weeks ago

Thanks for taking a look. I've just now emailed you a link to the files.

For what it's worth, I think that the error is triggered here: https://github.com/andersonwinkler/PALM/blob/762ba37a014247aa6b7aa3f6e4657c697905fbd6/fileio/%40gifti/save.m#L191-L192

At this point, the metadata field is an empty cell array

>> this.data{1}.metadata

ans = 

  struct with fields:

     name: 'Name'
    value: {}

Using that empty cell array with fprintf with this leads to the error (now with the helpful specification of which function was being called with cell inputs)

>> fprintf(fid,'%s<Value><![CDATA[%s]]></Value>\n',o(4),this.data{i}.metadata(1).value)
Error using fprintf
Function is not defined for 'cell' inputs.
andersonwinkler commented 2 weeks ago

Hi Patrick, I've just made a commit that should hopefully fix the problem. Could you try with this updated version? Thanks! Anderson

psadil commented 2 weeks ago

Looks good, thanks!