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

Error in Multilevel mediation fMRI walkthrough : Woo_2015_PlosBio_BMRK3_pain_6levels dataset example #31

Open
dylansutterlin opened this issue Mar 26, 2024 · 1 comment

Comments

@dylansutterlin
Copy link

Hi,
I was going through the mediation_brain_multilevel_walkthrough1.html tutorial to run multi-level mediation analysis. While trying to figure out how to format my data to run the mediation_brain_multilevel function , I got stuck running the example code. I entered exactly the first 3 code blocks. I am working on matlab2023a. I also reproduced the error on a collegue's computer.

`%% canlab example
metadata_file = which('bmrk3_6levels_metadata.mat');

if isempty(metadata_file)
disp('You need the dataset Woo_2015_PlosBio_BMRK3_pain_6levels on your Matlab path.')
disp('This is in the CANlab Core toolbox.')
error('Check path and files.')
end
load(metadata_file);
% Re-find local path names for brain images
M = single_trial_image_names;
dir_old = fileparts(M{1});
dir_new = fileparts(metadata_file);
for i = 1:length(M), M{i} = strrep(M{i}, dir_old, dir_new); end
single_trial_image_names = M;
X = temperatures;
Y = ratings;
whos X Y single_trial_image_names

mkdir mediation_results
cd mediation_results
SETUP.mask = which('gray_matter_mask.nii');
SETUP.preprocX = 0;
SETUP.preprocY = 0;
SETUP.preprocM = 0;
% mediation_brain_multilevel(X, Y, M, [other inputs])
mediation_brain_multilevel(temperatures, ratings, single_trial_image_names, SETUP);
`

Full output !

`Search for mediators
Warning! Unrecognized field in SETUPions structure SETUP.
Warning! Unrecognized field in SETUPions structure SETUP.
First-level covariates: None
Second-level moderators: None
Found mask: /home/dsutterlin/projects/genPain/Toolboxes/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/gray_matter_mask.nii
Preparing data.
Mask info:
Dimensions: 79 95 68
Voxels in mask: 195612
Mapping all input data volumes to memory
Subject 1, 1 images.
Subject 2, 1 images.
Subject 3, 1 images.
Subject 4, 1 images.
Subject 5, 1 images.
Subject 6, 1 images.
Subject 7, 1 images.
Subject 8, 1 images.
Subject 9, 1 images.
Subject 10, 1 images.
Subject 11, 1 images.
Subject 12, 1 images.
Subject 13, 1 images.
Subject 14, 1 images.
Subject 15, 1 images.
Subject 16, 1 images.
Subject 17, 1 images.
Subject 18, 1 images.
Subject 19, 1 images.
Subject 20, 1 images.
Subject 21, 1 images.
Subject 22, 1 images.
Subject 23, 1 images.
Subject 24, 1 images.
Subject 25, 1 images.
Subject 26, 1 images.
Subject 27, 1 images.
Subject 28, 1 images.
Subject 29, 1 images.
Subject 30, 1 images.
Subject 31, 1 images.
Subject 32, 1 images.
Subject 33, 1 images.
Preprocessing is Off
...Creating: X-M_effect
...Creating: M-Y_effect
...Creating: X-Y_direct_effect
...Creating: X-Y_total_effect
...Creating: X-M-Y_effect
...Creating: X-M_ste
...Creating: M-Y_ste
...Creating: X-Y_direct_ste
...Creating: X-Y_total_ste
...Creating: X-M-Y_ste
...Creating: X-M_pvals
...Creating: M-Y_pvals
...Creating: X-Y_direct_pvals
...Creating: X-Y_total_pvals
...Creating: X-M-Y_pvals
...Creating: X-M_indiv_effect
...Creating: M-Y_indiv_effect
...Creating: X-Y_direct_indiv_effect
...Creating: X-Y_total_indiv_effect
...Creating: X-M-Y_indiv_effect
...Creating: X-M_indiv_ste
...Creating: M-Y_indiv_ste
...Creating: X-Y_direct_indiv_ste
...Creating: X-Y_total_indiv_ste
...Creating: X-M-Y_indiv_ste
Outputs: 25 images
X-M_effect.img - 1 volume(s)
M-Y_effect.img - 1 volume(s)
X-Y_direct_effect.img - 1 volume(s)
X-Y_total_effect.img - 1 volume(s)
X-M-Y_effect.img - 1 volume(s)
X-M_ste.img - 1 volume(s)
M-Y_ste.img - 1 volume(s)
X-Y_direct_ste.img - 1 volume(s)
X-Y_total_ste.img - 1 volume(s)
X-M-Y_ste.img - 1 volume(s)
X-M_pvals.img - 1 volume(s)
M-Y_pvals.img - 1 volume(s)
X-Y_direct_pvals.img - 1 volume(s)
X-Y_total_pvals.img - 1 volume(s)
X-M-Y_pvals.img - 1 volume(s)
X-M_indiv_effect.img - 33 volume(s)
M-Y_indiv_effect.img - 33 volume(s)
X-Y_direct_indiv_effect.img - 33 volume(s)
X-Y_total_indiv_effect.img - 33 volume(s)
X-M-Y_indiv_effect.img - 33 volume(s)
X-M_indiv_ste.img - 1 volume(s)
M-Y_indiv_ste.img - 1 volume(s)
X-Y_direct_indiv_ste.img - 1 volume(s)
X-Y_total_indiv_ste.img - 1 volume(s)
X-M-Y_indiv_ste.img - 1 volume(s)

This will be evaluated at each voxel:
[out1,out2,out3,out4,out5,out6,out7,out8,out9,out10,out11,out12,out13,out14,out15,out16,out17,out18,out19,out20,out21,out22,out23,out24,out25] = fhandle(Y);

Slice 1, 1005 in-mask voxels
Loading and preprocessing for this slice for subject: Summary of missing or bad voxels:
Dataset 1: 0 voxels have no data, and 0 voxels have missing data.
Dataset 2: 0 voxels have no data, and 0 voxels have missing data.
Dataset 3: 0 voxels have no data, and 0 voxels have missing data.
Dataset 4: 0 voxels have no data, and 0 voxels have missing data.
Dataset 5: 0 voxels have no data, and 0 voxels have missing data.
Dataset 6: 0 voxels have no data, and 0 voxels have missing data.
Dataset 7: 0 voxels have no data, and 0 voxels have missing data.
Dataset 8: 0 voxels have no data, and 0 voxels have missing data.
Dataset 9: 0 voxels have no data, and 0 voxels have missing data.
Dataset 10: 0 voxels have no data, and 0 voxels have missing data.
Dataset 11: 0 voxels have no data, and 0 voxels have missing data.
Dataset 12: 0 voxels have no data, and 0 voxels have missing data.
Dataset 13: 0 voxels have no data, and 0 voxels have missing data.
Dataset 14: 0 voxels have no data, and 0 voxels have missing data.
Dataset 15: 0 voxels have no data, and 0 voxels have missing data.
Dataset 16: 0 voxels have no data, and 0 voxels have missing data.
Dataset 17: 0 voxels have no data, and 0 voxels have missing data.
Dataset 18: 0 voxels have no data, and 0 voxels have missing data.
Dataset 19: 0 voxels have no data, and 0 voxels have missing data.
Dataset 20: 0 voxels have no data, and 0 voxels have missing data.
Dataset 21: 0 voxels have no data, and 0 voxels have missing data.
Dataset 22: 0 voxels have no data, and 0 voxels have missing data.
Dataset 23: 0 voxels have no data, and 0 voxels have missing data.
Dataset 24: 0 voxels have no data, and 0 voxels have missing data.
Dataset 25: 0 voxels have no data, and 0 voxels have missing data.
Dataset 26: 0 voxels have no data, and 0 voxels have missing data.
Dataset 27: 0 voxels have no data, and 0 voxels have missing data.
Dataset 28: 0 voxels have no data, and 0 voxels have missing data.
Dataset 29: 0 voxels have no data, and 0 voxels have missing data.
Dataset 30: 0 voxels have no data, and 0 voxels have missing data.
Dataset 31: 0 voxels have no data, and 0 voxels have missing data.
Dataset 32: 0 voxels have no data, and 0 voxels have missing data.
Dataset 33: 0 voxels have no data, and 0 voxels have missing data.
Elapsed: 0 s
Analysis ...Error using tcdf
Degrees of freedom must be positive.

Error in mediation>get_ols_stats (line 1514)
stats.p = min(1, (2 .* (1 - tcdf(abs(stats.t), stats.df))));

Error in mediation (line 305)
stats = get_ols_stats(paths(i,:) , sterrs(i,:), n(i), num_additionalM); % setup dummy stats structure

Error in mediation_brain_multilev_wrapper (line 28)
[indiv_paths, toplevelstats, firstlevelstats] = mediation(X, Y, M, varargin{:});

Error in mediation_brain_multilevel>@(M)mediation_brain_multilev_wrapper(X,Y,M,varargin{:}) (line 110)
fhandle = @(M) mediation_brain_multilev_wrapper(X, Y, M, varargin{:});

Error in image_eval_function_multisubj/analyze_slice_data (line 333)
eval(fstr)

Error in image_eval_function_multisubj (line 272)
sliceoutputs = analyze_slice_data;

Error in mediation_brain_multilevel (line 181)
image_eval_function_multisubj(M, fhandle, 'mask', SETUP.mask, 'preprochandle', preprochandle, 'outnames', SETUP.outputnames, 'start', SETUP.startslice);
`
See attached image for only the error message. Thanks for any support/suggrestions!
Best
image

@dylansutterlin
Copy link
Author

Turns out that you need to remove the SPM(12 in my case)/external folder and its subfolder from path. This fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant