Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] GLM contrasting #1328

Open
4 of 9 tasks
CerenB opened this issue Nov 21, 2024 · 1 comment
Open
4 of 9 tasks

[BUG] GLM contrasting #1328

CerenB opened this issue Nov 21, 2024 · 1 comment
Labels
bug 🐛 Something isn't working

Comments

@CerenB
Copy link
Collaborator

CerenB commented Nov 21, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Operating system

  • Linux
  • Mac
  • Windows

Operating system version

  • Mac OS Version 10.15 "catalina"

SPM 12 version

  • 7771
  • 7487
  • 7219

Platform

  • MATLAB
  • Octave

Platform version

  • MATLAB 2017b

bidspm version

v3.1.0

bidspm branch / commit number

Expected Behavior

I'm certain that my issue is related to GLM model. I can run the GLM estimate but the contrast is giving an error.

Here is my script:

if GLM_FIRST_LEVEL
    
    for iSmooth = 1:length(fwhm)
        
        for i = 1:length(subject_label)
            
            % prepare to print the results
            results = defaultResultsStructure();
            
            opt.subjects = cell(1,1);
            
            results(1).nodeName = 'subject_level';
            results(1).name = {'Hand_gt_All','Feet_gt_All', ...
                               'Lips_gt_All', 'Tongue_gt_All', 'Forehead_gt_All'};
            
            results(1).MC = 'none';
            results(1).p = 0.001;
            results(1).k = 0;
            results(1).threshSpm = true();
            results(1).png = true();
            results(1).csv = true();
            results(1).binary = true();
            results(1).nidm = true();
            results(1).montage.do = true();
            results(1).montage.slices = 4:4:76;
            results(1).montage.orientation = 'axial';
            results(1).montage.background = struct('sub', opt.subjects{1}, ...
                                                   'suffix', 'T1w', ...
                                                   'desc', 'preproc', ...
                                                   'modality', 'anat');            
            results(2) = results;
            results(2).MC = 'FWE';
            results(2).p = 0.05;
            
            opt.results = results;
            
            bidspm(bids_dir, output_dir, 'subject', ...
                'action', 'stats', ...
                'participant_label', subject_label(i), ...
                'preproc_dir', preproc_dir, ...
                'model_file', model_file, ...
                'dry_run', dry_run, ...
                'verbosity', verbosity, ...
                'fwhm', fwhm{iSmooth}, ...
                'concatenate', false, ...
                'options', opt);
            
        end        
    end    
end

BIDS stats model

{
  "Name": "mototopy",
  "BIDSModelVersion": "1.0.0",
  "Description": "contrasts for the mototopy design dataset",
  "Input": {
    "task": [
      "mototopy"
    ],
    "space": [
      "T1w"
    ]
  },
  "Nodes": [
    {
      "Level": "Run",
      "Name": "run_level",
      "GroupBy": [
        "run",
        "subject"
      ],
      "Model": {
        "Type": "glm",
        "X": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead",
          "trial_type.hand_subjectCue",
          "trial_type.feet_subjectCue",
          "trial_type.tongue_subjectCue",
          "trial_type.lips_subjectCue",
          "trial_type.forehead_subjectCue",
          "trans_x", "trans_y", "trans_z", "rot_x", "rot_y", "rot_z"
        ],
        "HRF": {
          "Variables": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Model": "spm"
        },
        "Options": {
          "HighPassFilterCutoffHz": 0.008,
          "Mask": {
            "suffix": [
              "mask"
            ],
            "desc": [
              "brain"
            ]
          }
        },
        "Software": {
          "SPM": {
            "InclusiveMaskingThreshold": "0.78",
            "SerialCorrelation": "FAST"
          }
        }
      },
      "DummyContrasts": {
        "Test": "t",
        "Contrasts": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead",
          "trial_type.hand_subjectCue",
          "trial_type.feet_subjectCue",
          "trial_type.tongue_subjectCue",
          "trial_type.lips_subjectCue",
          "trial_type.forehead_subjectCue"
        ]
      },
      "Contrasts": [
        {
          "Name": "Hand_gt_All",
          "ConditionList": [
            "trial_type.block_hand",
            "trial_type.block_feet",
            "trial_type.block_tongue",
            "trial_type.block_lips",
            "trial_type.block_forehead"
          ],
          "Weights": [1, -0.25, -0.25, -0.25, -0.25],
          "Test": "t"
        },
        {
         "Name": "Foot_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, 1, -0.25, -0.25, -0.25],
          "Test": "t"
        },
        {
         "Name": "Forehead_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, -0.25, -0.25, 1],
          "Test": "t"
        },
        {
        "Name": "Lips_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, -0.25, 1, -0.25],
          "Test": "t"
        },
        {
        "Name": "Tongue_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, 1, -0.25, -0.25],
          "Test": "t"
        }
      ]
    },
    {
      "Level": "Subject",
      "Name": "subject_level",
      "GroupBy": [
        "contrast",
        "subject"
      ],
      "Model": {
        "Type": "glm",
        "X": [
          1
        ]
      },
      "DummyContrasts": {
        "Test": "t"
      }
    },
    {
      "Level": "Dataset",
      "Name": "dataset_level",
      "GroupBy": [
        "contrast"
      ],
      "Model": {
        "X": [
          1
        ],
        "Type": "glm",
        "Software": {
          "SPM": {
            "SerialCorrelation": "FAST"
          }
        }
      },
      "DummyContrasts": {
        "Test": "t"
      }
    }
  ]
}

Current Behavior & Error message

K>> contrasts(weightVectorIsAllZero).name
Function 'subsindex' is not defined for values
of class 'cell'.
 
K>> weightVectorIsAllZero

weightVectorIsAllZero =

  1×66 cell array

  Columns 1 through 5

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 6 through 10

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 11 through 15

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 16 through 20

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 21 through 25

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 26 through 30

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 31 through 35

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 36 through 40

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 41 through 45

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 46 through 50

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 51 through 55

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 56 through 60

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Columns 61 through 65

    {[0]}    {[0]}    {[0]}    {[0]}    {[0]}

  Column 66

    {[1]}


[14:50:26] bidspm - INFO				
Function 'subsindex' is not defined for values of class 'cell'.
 Error MATLAB:UndefinedFunction occurred:
	- Error in validateContrasts
		line 30 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/stats/utils/validateContrasts.m
	- Error in appendContrast
		line 32 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/stats/subject_level/appendContrast.m
	- Error in addExplicitDummyContrasts
		line 138 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/stats/subject_level/specifyDummyContrasts.m
	- Error in specifyDummyContrasts
		line 37 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/stats/subject_level/specifyDummyContrasts.m
	- Error in specifyContrasts
		line 64 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/stats/subject_level/specifyContrasts.m
	- Error in setBatchSubjectLevelContrasts
		line 42 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/batches/stats/setBatchSubjectLevelContrasts.m
	- Error in bidsFFX
		line 120 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/workflows/stats/bidsFFX.m
	- Error in runContrasts
		line 127 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/cli/cliStats.m
	- Error in cliStats
		line 86 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/src/cli/cliStats.m
	- Error in executeAction
		line 86 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/bidspm.m
	- Error in bidspm
		line 26 in /Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/code/src/bidspm-stats/../../lib/bidspm/bidspm.m

ERROR LOG SAVED:
	/Volumes/extreme/Cerens_files/fMRI/moebius_topo_analyses/outputs/derivatives/error_logs/error_2024-11-21T14-50.log
Use it when opening an issue:
	https://github.com/cpp-lln-lab/bidspm/issues/new/choose.

Function 'subsindex' is not defined for values of class
'cell'.

Error in validateContrasts (line 30)
    names = contrasts(weightVectorIsAllZero).name;

Error in appendContrast (line 32)
  validateContrasts(contrasts);

Error in
specifyDummyContrasts>addExplicitDummyContrasts (line
138)
        [contrasts, counter] =
        appendContrast(contrasts, C, counter,
        testType);

Error in specifyDummyContrasts (line 37)
  [contrasts, counter] =
  addExplicitDummyContrasts(model, node, contrasts,
  counter);

Error in specifyContrasts (line 64)
    [contrasts, counter] = specifyDummyContrasts(model,
    node, contrasts, counter);

Error in setBatchSubjectLevelContrasts (line 42)
    contrasts = specifyContrasts(bm, SPM);

Error in bidsFFX (line 120)
        matlabbatch =
        setBatchSubjectLevelContrasts(matlabbatch, opt,
        subLabel, nodeName);

Error in cliStats>runContrasts (line 127)
    bidsFFX('contrasts', opt);

Error in cliStats (line 86)
        runContrasts(isSubjectLevel, opt, nodeName,
        concatenate);

Error in bidspm>executeAction (line 86)
      cliStats(varargin{2:end});

Error in bidspm (line 26)
    returnCode = executeAction(action, varargin{:});

error_2024-11-21T14-50.log

Anything else?

No response

@CerenB CerenB added the bug 🐛 Something isn't working label Nov 21, 2024
@CerenB CerenB changed the title [BUG] [BUG] GLM contrasting Nov 22, 2024
@CerenB
Copy link
Collaborator Author

CerenB commented Nov 22, 2024

I did change the model file, but still have the same error.

Function 'subsindex' is not defined for values of class 'cell'.

{
  "Name": "mototopy",
  "BIDSModelVersion": "1.0.0",
  "Description": "contrasts for the mototopy design dataset",
  "Input": {
    "task": [
      "mototopy"
    ],
    "space": [
      "T1w"
    ]
  },
  "Nodes": [
    {
      "Level": "Run",
      "Name": "run_level",
      "GroupBy": [
        "run",
        "subject"
      ],
      "Model": {
        "Type": "glm",
        "X": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead",
          "trial_type.hand_subjectCue",
          "trial_type.feet_subjectCue",
          "trial_type.tongue_subjectCue",
          "trial_type.lips_subjectCue",
          "trial_type.forehead_subjectCue",
          "trans_x", "trans_y", "trans_z", "rot_x", "rot_y", "rot_z"
        ],
        "HRF": {
          "Variables": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Model": "spm"
        },
        "Options": {
          "HighPassFilterCutoffHz": 0.008,
          "Mask": {
            "suffix": [
              "mask"
            ],
            "desc": [
              "brain"
            ]
          }
        },
        "Software": {
          "SPM": {
            "InclusiveMaskingThreshold": "0.78",
            "SerialCorrelation": "FAST"
          }
        }
      },
      "DummyContrasts": {
        "Test": "t",
        "Contrasts": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead",
          "trial_type.hand_subjectCue",
          "trial_type.feet_subjectCue",
          "trial_type.tongue_subjectCue",
          "trial_type.lips_subjectCue",
          "trial_type.forehead_subjectCue"
        ]
      }
    },
    {
      "Level": "Subject",
      "Name": "subject_level",
      "GroupBy": [
        "contrast",
        "subject"
      ],
      "Model": {
        "Type": "glm",
        "X": [
          1
        ]
      },
      "Contrasts": [
        {
          "Name": "Hand_gt_All",
          "ConditionList": [
            "trial_type.block_hand",
            "trial_type.block_feet",
            "trial_type.block_tongue",
            "trial_type.block_lips",
            "trial_type.block_forehead"
          ],
          "Weights": [1, -0.25, -0.25, -0.25, -0.25],
          "Test": "t"
        },
        {
         "Name": "Foot_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, 1, -0.25, -0.25, -0.25],
          "Test": "t"
        },
        {
         "Name": "Forehead_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, -0.25, -0.25, 1],
          "Test": "t"
        },
        {
        "Name": "Lips_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, -0.25, 1, -0.25],
          "Test": "t"
        },
        {
        "Name": "Tongue_gt_All",
          "ConditionList": [
          "trial_type.block_hand",
          "trial_type.block_feet",
          "trial_type.block_tongue",
          "trial_type.block_lips",
          "trial_type.block_forehead"
          ],
          "Weights": [-0.25, -0.25, 1, -0.25, -0.25],
          "Test": "t"
        }
      ],
      "DummyContrasts": {
        "Test": "t"
      }
    },
    {
      "Level": "Dataset",
      "Name": "dataset_level",
      "GroupBy": [
        "contrast"
      ],
      "Model": {
        "X": [
          1
        ],
        "Type": "glm",
        "Software": {
          "SPM": {
            "SerialCorrelation": "FAST"
          }
        }
      },
      "DummyContrasts": {
        "Test": "t"
      }
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant