canlab / MediationToolbox

Single-level and multi-level mediation analyses for any kind of data, with bootstrap-based significance testing. Neuroimaging-oriented functions allow for mediation effect parametric mapping (mapping of mediation effects across the brain) and multivariate mediation.
https://canlabweb.colorado.edu/wiki/doku.php/help/mediation/m3_mediation_fmri_toolbox
78 stars 28 forks source link

Issue running mediation_brain #25

Open vscholz118 opened 2 years ago

vscholz118 commented 2 years ago

Hello everyone, This is the first time I'm trying to run a mediation analysis using this toolbox and I've run into some trouble.

Entering this line of code in matlab (Version 2021b) results = mediation_brain(X,Y,M,'names',names,'mask', mask, 'noverbose');

I get the following error (copied below) which at first glance seems to be related to the tcdf code from matlab... but is it really required to have the Deep Learning Coder and the Deep Learning Toolbox installed for running the mediation? Because this is what I found online as suggestion to resolve part of the error message "Unable to resolve the name coder.internal.sxalloc".

Unfortunately I don't currently have the Deep Learning Toolbox for matlab ..... Any help is much appreciated, as running this analysis would help me finish a project :-)

Thank you and best wishes, Vanessa

------------

Mask: C:\Matlab\CanlabCore-master\CanlabCore-master\CanlabCore\canlab_canonical_brains\Canonical_brains_surfaces\gray_matter_mask.img Rank data: No

Reading data.Direct calls to spm_defauts are deprecated. Please use spm('Defaults',modality) or spm_get_defauStatistics.

Slice 1 : 3318 voxels in-mask Unable to resolve the name coder.internal.sxalloc.

Error in tcdf (line 16) p = coder.internal.sxalloc([true,isfloat(v)],x,v);

Error in mediation>get_ols_stats (line 1511) 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_search (line 143) [paths, stat] = mediation(X, Y, M(:,region), varargin{:}, 'persistent', extra_args{:}, 'pvals_for_boot', pvals_for_boot, 'arorder', arorder);

Error in mediation_brain/process_slice (line 314) slice_results = mediation_search('M', X, Y, M(:,whvox), varargin{:});

Error in mediation_brain (line 276) process_slice();

Error in mediation_M3_1000 (line 158) results = mediation_brain(X,Y,M,'names',names,'mask', mask, 'noverbose');

torwager commented 2 years ago

Hi - tcdf is in the stats toolbox, which you do need. It’s possible that you have another function called tcdf higher on your path that does something else, which wouldn’t be advised…

Best wishes, Tor


On Dec 7, 2021, at 6:12 AM, vscholz118 @.***> wrote:

Hello everyone, This is the first time I'm trying to run a mediation analysis using this toolbox and I've run into some trouble.

Entering this line of code in matlab (Version 2021b) results = mediation_brain(X,Y,M,'names',names,'mask', mask, 'noverbose');

I get the following error (copied below) which at first glance seems to be related to the tcdf code from matlab... but is it really required to have the Deep Learning Coder and the Deep Learning Toolbox installed for running the mediation? Because this is what I found online as suggestion to resolve part of the error message "Unable to resolve the name coder.internal.sxalloc".

Unfortunately I don't currently have the Deep Learning Toolbox for matlab ..... Any help is much appreciated, as running this analysis would help me finish a project :-)

Thank you and best wishes, Vanessa

------------

Mask: C:\Matlab\CanlabCore-master\CanlabCore-master\CanlabCore\canlab_canonical_brains\Canonical_brains_surfaces\gray_matter_mask.img Rank data: No

Reading data.Direct calls to spm_defauts are deprecated. Please use spm('Defaults',modality) or spm_get_defauStatistics.

Slice 1 : 3318 voxels in-mask Unable to resolve the name coder.internal.sxalloc.

Error in tcdf (line 16) p = coder.internal.sxalloc([true,isfloat(v)],x,v);

Error in mediation>get_ols_stats (line 1511) 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_search (line 143) [paths, stat] = mediation(X, Y, M(:,region), varargin{:}, 'persistent', extra_args{:}, 'pvals_for_boot', pvals_for_boot, 'arorder', arorder);

Error in mediation_brain/process_slice (line 314) slice_results = mediation_search('M', X, Y, M(:,whvox), varargin{:});

Error in mediation_brain (line 276) process_slice();

Error in mediation_M3_1000 (line 158) results = mediation_brain(X,Y,M,'names',names,'mask', mask, 'noverbose');

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/canlab/MediationToolbox/issues/25, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABPY7LGOEAKZWWATEKTCPCLUPXTYTANCNFSM5JQ7DZSA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

vscholz118 commented 2 years ago

Hello Tor, First, thank you for your quick reply and second, apologies for my late reply.

I reset all my paths and while the aforementioned error disappeared, I got a new error message (pasted below). Unfortunately, I'm not sure what to make of it or how to further isolate the source of the error.

For my analysis, I enter age and a second data column with format double as X and Y, use the suggested canlab mask and create a 4D nii.gz file from my preprocessed T1 images as M, similar to the nii.gz file based on the contrast images for the sample data. Reading in 3D nii files or 4 D nii did not work for me, as I always got an error message saying that none of the entries was a list. Of note, I ran the example code for mediation_brain on the sample data and this works, so I think it must be something about the way I'm feeding the structural data to the toolbox, though I'm at a loss what might be the issue. Any help is very much appreciated!

Best wishes, Vanessa

-------------------------------------------

Slice 1 : 3318 voxels in-mask Error using tcdf (line 30) Degrees of freedom must be positive.

Error in mediation>get_ols_stats (line 1511) 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_search (line 143) [paths, stat] = mediation(X, Y, M(:,region), varargin{:}, 'persistent', extra_args{:}, 'pvals_for_boot', pvals_for_boot, 'arorder', arorder);

Error in mediation_brain/process_slice (line 314) slice_results = mediation_search('M', X, Y, M(:,whvox), varargin{:});

Error in mediation_brain (line 276) process_slice();