[RESOLVED] Error with PALM design matrix

Description:

I would like to fit a GLM to the preprocessed BOLD time series data. My model has two predictors and it is a within-subject design. I am using create_ws_palm_design to create the design. The function runs without issue, but when running run_palm, I get an error saying that there is a mismatch between the rows in the matrix and the observations in the data. I am using version 0.92. I am providing an example call below.

Call:
qunex create_ws_palm_design
–factors=‘1,1’
–nsubjects=9
–root=“/gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session”

qunex run_palm
–image=“/gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/processing/lists/lang-math-by-session.dtseries.nii”
–design=“name:/gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session”
–root=“/gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session”
–overwrite=“yes”

Log:

Starting log for PALM Left Surface at 2024-05-13 17:34:58
The command being run:

palm -i /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii -m /opt/qunex/qx_library/data/atlases/hcp/masks/surface.cifti.L.mask.32k_fs_LR.func.gii -s /opt/qunex/qx_library/data/atlases/hcp/Q1-Q6_R440.L.midthickness.32k_fs_LR.surf.gii -d /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_d.csv -t /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_t.csv -f /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_f.csv -eb /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_eb.csv -n 100 -zstat -o /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_L

=======================================================================
___ ___ ___
/ /\ / /\ //
/ /::\ / /::\ | |::
/ /:/:\ / /:/:\ ___ ___ | |:|:
/ /:/~/:confused: / /:/~/::\ /
/\ / /\ ||:|:
//:confused: /:confused: //:confused: /:/:\ \ :\ / /:confused: //::::expressionless: :
\ :/:confused: \ :/:confused:
/ \ :\ /:confused: \ :~~_/
\ ::confused: \ ::confused: \ :/:confused: \ :
\ :\ \ :\ \ ::confused: \ :
\ :\ \ :\ _
/ \ :
_/ _/ __/

=======================================================================
Permutation Analysis of Linear Models

Running PALM (github using Octave 4.4.1 with the following options:
-i /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii
-m /opt/qunex/qx_library/data/atlases/hcp/masks/surface.cifti.L.mask.32k_fs_LR.func.gii
-s /opt/qunex/qx_library/data/atlases/hcp/Q1-Q6_R440.L.midthickness.32k_fs_LR.surf.gii
-d /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_d.csv
-t /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_t.csv
-f /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_f.csv
-eb /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_eb.csv
-n 100
-zstat
-o /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_L
Found FSL in /opt/fsl/fsl
Found FreeSurfer in /opt/freesurfer/freesurfer
Found HCP Workbench executable in /opt/workbench/workbench/bin_rh_linux64/wb_command
warning: function /opt/palm/palm-o/colourmaps/viridis.m shadows a core library function
Reading input 1/1: /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii
Reading design matrix and contrasts.
Error using palm_miscread (/opt/palm/palm-o/palm_miscread.m:103)
load: unable to determine file format of ‘/gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_t.csv’

Error in palm_takeargs (/opt/palm/palm-o/palm_takeargs.m:2115->palm_miscread)
Error in palm_core (/opt/palm/palm-o/palm_core.m:33->palm_takeargs)
Error in palm (/opt/palm/palm-o/palm.m:81->palm_core)
Starting log for PALM Left Surface at 2024-05-14 11:22:47
The command being run:

palm -i /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii -m /opt/qunex/qx_library/data/atlases/hcp/masks/surface.cifti.L.mask.32k_fs_LR.func.gii -s /opt/qunex/qx_library/data/atlases/hcp/Q1-Q6_R440.L.midthickness.32k_fs_LR.surf.gii -d /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_d.csv -t /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_t.csv -f /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_f.csv -eb /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_eb.csv -n 100 -zstat -o /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_L

=======================================================================
___ ___ ___
/ /\ / /\ //
/ /::\ / /::\ | |::
/ /:/:\ / /:/:\ ___ ___ | |:|:
/ /:/~/:confused: / /:/~/::\ /
/\ / /\ ||:|:
//:confused: /:confused: //:confused: /:/:\ \ :\ / /:confused: //::::expressionless: :
\ :/:confused: \ :/:confused:
/ \ :\ /:confused: \ :~~_/
\ ::confused: \ ::confused: \ :/:confused: \ :
\ :\ \ :\ \ ::confused: \ :
\ :\ \ :\ _
/ \ :
_/ _/ __/

=======================================================================
Permutation Analysis of Linear Models

Running PALM (github using Octave 4.4.1 with the following options:
-i /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii
-m /opt/qunex/qx_library/data/atlases/hcp/masks/surface.cifti.L.mask.32k_fs_LR.func.gii
-s /opt/qunex/qx_library/data/atlases/hcp/Q1-Q6_R440.L.midthickness.32k_fs_LR.surf.gii
-d /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_d.csv
-t /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_t.csv
-f /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_f.csv
-eb /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_eb.csv
-n 100
-zstat
-o /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_L
Found FSL in /opt/fsl/fsl
Found FreeSurfer in /opt/freesurfer/freesurfer
Found HCP Workbench executable in /opt/workbench/workbench/bin_rh_linux64/wb_command
warning: function /opt/palm/palm-o/colourmaps/viridis.m shadows a core library function
Reading input 1/1: /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_i1_left.func.gii
Reading design matrix and contrasts.
Error using palm_takeargs (/opt/palm/palm-o/palm_takeargs.m:2062)
The number of rows in the design matrix does
not match the number of observations in the data.

  • Rows in the matrix: 9
  • Observations in the data: 18
    In file /gpfs/gibbs/pi/aslin/ss2569/Studies/fMRI_fNIRS_rerun4/analysis/final_analyses/ws_design_2factors/by_session/2predictors_by_session_d.csv

Error in palm_core (/opt/palm/palm-o/palm_core.m:33->palm_takeargs)
Error in palm (/opt/palm/palm-o/palm.m:81->palm_core)

Alonso, hi!

There is a mismatch in how you specify the model and how your data are organized. The create_ws_palm_design is built to create full factorial ANOVA models, which really make sense if you have factors with more than two levels. In your specification, you define a model with two factors, each with a single level. In terms of an ANOVA matrix, this collapses to a single cell of data, each cell has 9 participants, therefore there is only 9 rows in the prepared design matrix.

PALM reports that your data has 18 rows. So in your experiment each participant performed the task in two conditions. What was the difference between these conditions? Based on the data, my assumption would be that you had a single factor with two levels. In this case, specifying --factors='2' should be the correct specification in the call to create_ws_palm_design.

All the best,

Grega

Thanks, Grega. I have changed the factor specification following your advice. I have collected data from several subjects using Binder’s (2011) language localizer, which is the same localizer task used in the HCP dataset, so I am interested in the Story vs Math contrast. I have run, however, into another issue. When running the call below the following images are generated:

1factor_by_session_reg_ztstat_C1.dscalar.nii
1factor_by_session_reg_ztstat_C2.dscalar.nii
1factor_by_session_reg_ztstat_fwep_C1.dscalar.nii
1factor_by_session_reg_ztstat_fwep_C2.dscalar.nii
1factor_by_session_reg_ztstat_uncp_C1.dscalar.nii
1factor_by_session_reg_ztstat_uncp_C2.dscalar.nii

The images, however, all seem to be showing the contrast Math > Story. That is images 1factor_by_session_reg_ztstat_C1.dscalar.nii and 1factor_by_session_reg_ztstat_C2.dscalar.nii are exactly the same. I have saved the GLM estimates in a file organized by session and the extracted GLM volumes look as expected. Any ideas as to what may be the issue? Please let me know if it would be helpful to share the images or log files.

Call
qunex create_ws_palm_design
–factors=‘2’
–nsubjects=9
–root=“${WORK_DIR}/${STUDY_NAME}/${ANALYSIS}/1factor_by_session”

qunex run_palm
–image=“${WORK_DIR}/${STUDY_NAME}/processing/lists/lang-math-by-session.dtseries.nii”
–design=“name:${WORK_DIR}/${STUDY_NAME}/${ANALYSIS}/1factor_by_session”
–root=“${WORK_DIR}/${STUDY_NAME}/${ANALYSIS}/1factor_by_session”
–overwrite=“yes”

Thanks,
Sara

Sara,

If you are running an ANOVA-type analysis, then the results will be “undirected” and will only show you a presence of differences. This is what create_ws_palm_design is used for, creating contrasts for full factorial classical ANOVA analyses with estimation of main effects and interactions. If you want a directed comparison between two conditions, then you are better off running a t-test. We do not have a support function for generating design matrices for dependent t-test. The easiest way to run a dependent t-test is to compute the difference images (this would result in 9 images) and then run PALM on those. In this case no design matrix is needed.

All the best,

Grega

Thanks, Grega. This makes sense. I will compute the difference images and then run PALM.

Best,
Sara