problem with defining multi-level variables
Hannah-Savage opened this issue · 1 comments
Hi Tor and team,
I am hoping to use your toolbox to investigate the relationship between X: task activity/onsets, Y: SCR data, M: whole brain nii files, using the multi-level analysis method.
I have successfully run through the single-level mediation example provided.
In my data I have 25 subjects (but for brevity have included only 4 here). I have looked at the mediation_help pdf and I thought I had formatted and defined the X, Y, M and covariate variables correctly:
%%% This is the format of the variables I define %%%
load('Mediation_test_sample_onsets.mat');
x = group_onsets
x = 4×1 cell array
{1202×1 double}
{1202×1 double}
{1202×1 double}
{1202×1 double}
load('Mediation_test_sample_SCR.mat');
y = group_downsampled_data
y = 4×1 cell array
{1202×1 double}
{1202×1 double}
{1202×1 double}
{1202×1 double}
load('Mediation_test_sample_images.mat', 'image_files');
imgs = image_files
imgs = 4×1 cell array
{1202×1 string}
{1202×1 string}
{1202×1 string}
{1202×1 string}
%% image_files{1,1} looks like:
"/data/netapp01/work/hssavage/7T/2_PreprocessedData/7T02/swrReversal.nii,1 "
"/data/netapp01/work/hssavage/7T/2_PreprocessedData/7T02/swrReversal.nii,2 "
"/data/netapp01/work/hssavage/7T/2_PreprocessedData/7T02/swrReversal.nii,3 "
"/data/netapp01/work/hssavage/7T/2_PreprocessedData/7T02/swrReversal.nii,4 "
... up to swrReversal.nii,1202 %%
load('Mediation_test_sample_motion_covariates.mat');
%These are MRI motion regressors I would like to include as covariates of no interest%
covs = group_motion_covariates
covs = 4×1 cell array
{1202×19 double}
{1202×19 double}
{1202×19 double}
{1202×19 double}
I then run this:
mask=which('gray_matter_mask.img')
mask =
'/data/netapp01/work/hssavage/7T/MediationAnalysis/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/gray_matter_mask.img'
canlab_results_fmridisplay(mask,'compact2');
cd ('Test_results/')
mediation_brain_multilevel(group_onsets, group_downsampled_data, imgs, 'mask', mask, 'boot', 'nopreproc', 'covs', group_motion_covariates);
I get the following error message:
Field assignment to a non-structure array object.
Error in mediation_brain_multilevel (line 75)
[SETUP.cmdstring, SETUP.wh_is_mediator] = get_cmdstring(X, Y, M);
I have attached the 4 .mat variables/files that I am using, and was wondering if you might be able to identify why my 'M' variable is not able to be interpreted properly? I am assuming it's the M variable that is wrong, but it could be the others!
Thanks in advance for your help,
Hannah
Hi there,
I have solved the problem! The M variable was defined as a string (as per the Mediation_help file "M could be a string matrix of 20 image names (one subject's image per row, one image per subject"). It seems to actually require a char vector as per 'get_cmdstring'. I think I just misread how the data should be stored.
Hopefully I can get the rest to run!
Thanks for the toolbox,
Hannah