Mensen / ept_TFCE-matlab

Advanced EEG Statistics
28 stars 9 forks source link

Correlation #8

Open speters14 opened 7 years ago

speters14 commented 7 years ago

Hi Mensen,

I'm trying to use the correlation option with the TFCE code. I'm wondering what the format of the behavioral data should be? I've tried a few different things but I'm getting an error. I was looking to do 6 different behavioral measures (six scores) per subject (19 subjects). For my EEG data, though, I'm still using subject x chan x freq. Do I need to scale that down to one chan or one freq? Thanks.

Error using - Array dimensions must match for binary array op.

Error in ept_TFCE>@(x)(x-mean(x))./std(x) (line 325) condition = @(x) (x-mean(x))./std(x);

Error in ept_TFCE (line 334) T_Obs = (condition(Data{1})' * condition(behavior_repeated)) / sum(condition(Data{1}).^2);

Mensen commented 7 years ago

Hey!

The behavioural option is currently only capable of a single correlation. So the behavioural data should just be a single dimension vector of length n_participants.

If you want to measure 6 different correlations unfortunately you'll have to run each correlation separately for now.

The other way I'm currently working on is using linear mixed models with these 6 predictors... but unfortunately this is still too slow if you have more than just the channels (you mentioned you had multiple frequencies).

Hope this way is not too much of a bother for you. Let me know how you get on!

Mensen commented 7 years ago

I should also mention that the parameter settings for e and h (normally semi-hidden parameters) might not be optimal for correlation analysis (in particular the h parameter)... so you might want to test out a couple of different settings here (e.g. h = 1, or h = 3; default is 2) in case the results aren't quite what you are expecting. We can discuss this parameter more in detail if it turns out other settings than the default give more expected results.

speters14 commented 7 years ago

Great! Thanks

Sue Peters

On Aug 11, 2017 5:42 AM, "Armand Mensen" notifications@github.com wrote:

I should also mention that the parameter settings for e and h (normally semi-hidden parameters) might not be optimal for correlation analysis (in particular the h parameter)... so you might want to test out a couple of different settings here (e.g. h = 1, or h = 3; default is 2) in case the results aren't quite what you are expecting. We can discuss this parameter more in detail if it turns out other settings than the default give more expected results.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321770501, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xsX5i-KAO374ipmPh0k-9BAZS32iks5sXCIJgaJpZM4O0JFm .

speters14 commented 7 years ago

I'm still getting this error when I try to run, even with a single vector. I tried my summary data file in two different formats: 19 x124 (at one freq bin) or 19x124x141 (all freq bins). The behavior data is 19x1. Any tip for what i might be doing wrong? Thanks!

Error using - Matrix dimensions must agree.

Error in ept_TFCE>@(x)(x-mean(x))./std(x) (line 325) condition = @(x) (x-mean(x))./std(x);

Error in ept_TFCE (line 334) T_Obs = (condition(Data{1})' * condition(behavior_repeated)) / sum(condition(Data{1}).^2);

On Fri, Aug 11, 2017 at 9:37 AM, Sue Peters sp@suepeters.com wrote:

Great! Thanks

Sue Peters

On Aug 11, 2017 5:42 AM, "Armand Mensen" notifications@github.com wrote:

I should also mention that the parameter settings for e and h (normally semi-hidden parameters) might not be optimal for correlation analysis (in particular the h parameter)... so you might want to test out a couple of different settings here (e.g. h = 1, or h = 3; default is 2) in case the results aren't quite what you are expecting. We can discuss this parameter more in detail if it turns out other settings than the default give more expected results.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321770501, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xsX5i-KAO374ipmPh0k-9BAZS32iks5sXCIJgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

Mensen commented 7 years ago

So I couldn't reproduce the matrix dimension must agree error ... what version of matlab are you using?

I did find another error with multidimensional data for the correlation calculation and I fixed that in 3b44dcdbc77ee378bc285ff4625b385477ef9264, and maybe that fixed your particular error by magic? Probably not, but let me know what version you are using and I'll try to reproduce the error.

speters14 commented 7 years ago

Thanks. I'm using Matlab 2014a. I recently re-installed your code, as it had been a while since I used it. So I think all the code is updated, but will try with your latest changes as well.

Also, just trying now to use the ANOVA, repeated measures with gender as a factor. I have 12 subjects, 6 male and 6 female, at two ages. I'm trying to figure out arrange the data. Does this sound right: First file: 12x124x141 (freq bins) concatenated with 12x124x1(gender) for first age group Second file: same as above, but at the second time point/age for with the same subject order.

On Sat, Aug 12, 2017 at 10:25 AM, Armand Mensen notifications@github.com wrote:

So I couldn't reproduce the matrix dimension must agree ... what version of matlab are you using?

I did find another error with multidimensional data for the correlation calculation and I fixed that in 3b44dcd https://github.com/Mensen/ept_TFCE-matlab/commit/3b44dcdbc77ee378bc285ff4625b385477ef9264, and maybe that fixed your particular error by magic? Probably not, but let me know what version you are using and I'll try to reproduce the error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321984520, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xkgE_mgGc_pUCajDNw73246gla_4ks5sXbW9gaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

speters14 commented 7 years ago

Tried correlation again. Different error. I could update to newer Matlab. What version? Error using - Array dimensions must match for binary array op.

Error in ept_TFCE>@(x)(x-mean(x))./std(x) (line 329) condition = @(x) (x-mean(x))./std(x);

Error in ept_TFCE (line 338) temp_observed = [reshape(condition(Data{1}), nA, [])' ...

On Sat, Aug 12, 2017 at 10:50 AM, Sue Peters sp@suepeters.com wrote:

Thanks. I'm using Matlab 2014a. I recently re-installed your code, as it had been a while since I used it. So I think all the code is updated, but will try with your latest changes as well.

Also, just trying now to use the ANOVA, repeated measures with gender as a factor. I have 12 subjects, 6 male and 6 female, at two ages. I'm trying to figure out arrange the data. Does this sound right: First file: 12x124x141 (freq bins) concatenated with 12x124x1(gender) for first age group Second file: same as above, but at the second time point/age for with the same subject order.

On Sat, Aug 12, 2017 at 10:25 AM, Armand Mensen notifications@github.com wrote:

So I couldn't reproduce the matrix dimension must agree ... what version of matlab are you using?

I did find another error with multidimensional data for the correlation calculation and I fixed that in 3b44dcd https://github.com/Mensen/ept_TFCE-matlab/commit/3b44dcdbc77ee378bc285ff4625b385477ef9264, and maybe that fixed your particular error by magic? Probably not, but let me know what version you are using and I'll try to reproduce the error.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321984520, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xkgE_mgGc_pUCajDNw73246gla_4ks5sXbW9gaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025 <(646)%20337-7025>

www.linkedin.com/in/suepeters

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

Mensen commented 7 years ago

I've recently been seeing a lot of problems with things pre-2014b... I think Matlab made a lot of changes to more basic functions after that, and since I usually keep up-to-date with Matlab, it becomes difficult to make sure things are backwards compatible. I have 2014a on another computer for this reason, and I'll try it out there and see if I can get a workaround for these older versions.

If you can get your hands on the newest possible one (I think still 2017a for now), then this should be fine. However, I think even 2014b should make a difference.


In regards to the ANOVA... your data should be structured in a 2 x 2 cell array. So a 6 x 124 x 141 in each cell array just keeping consistent across the dimensions (e.g. gender differences in columns, and age differences in the rows... or the other way, just not mixed).

speters14 commented 7 years ago

Thanks Armand!! =)

On Sat, Aug 12, 2017 at 11:40 AM, Armand Mensen notifications@github.com wrote:

I've recently been seeing a lot of problems with things pre-2014b... I think Matlab made a lot of changes to more basic functions after that, and since I usually keep up-to-date with Matlab, it becomes difficult to make sure things are backwards compatible. I have 2014a on another computer for this reason, and I'll try it out there and see if I can get a workaround for these older versions.

If you can get your hands on the newest possible one (I think still 2017a for now), then this should be fine. However, I think even 2014b should make a difference.

In regards to the ANOVA... your data should be structured in a 2 x 2 cell array. So a 6 x 124 x 141 in each cell array just keeping consistent across the dimensions (e.g. gender differences in columns, and age differences in the rows... or the other way, just not mixed).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321988742, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xrEDVtpA5iUx_mMrGT9PE4UC6l77ks5sXceIgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

speters14 commented 7 years ago

The ANOVA function asks for two data files (2 groups) group 1 condition and group 2 condition. So how does this fit with a 2x2 cell array with all of the data (from both groups) in one file? or do I create 2 separate 1x2 cell arrays, or set it as 1 group in the initial viewer/gui, and just upload one data file?

On Sat, Aug 12, 2017 at 11:47 AM, Sue Peters sp@suepeters.com wrote:

Thanks Armand!! =)

On Sat, Aug 12, 2017 at 11:40 AM, Armand Mensen notifications@github.com wrote:

I've recently been seeing a lot of problems with things pre-2014b... I think Matlab made a lot of changes to more basic functions after that, and since I usually keep up-to-date with Matlab, it becomes difficult to make sure things are backwards compatible. I have 2014a on another computer for this reason, and I'll try it out there and see if I can get a workaround for these older versions.

If you can get your hands on the newest possible one (I think still 2017a for now), then this should be fine. However, I think even 2014b should make a difference.

In regards to the ANOVA... your data should be structured in a 2 x 2 cell array. So a 6 x 124 x 141 in each cell array just keeping consistent across the dimensions (e.g. gender differences in columns, and age differences in the rows... or the other way, just not mixed).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321988742, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xrEDVtpA5iUx_mMrGT9PE4UC6l77ks5sXceIgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025 <(646)%20337-7025>

www.linkedin.com/in/suepeters

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

speters14 commented 7 years ago

Just FYI, I tried correlation on another computer of mine with 15a installed, and same error as last time. Maybe there's a problem with my data structures (attached). I will try installing 2017 and running again.

On Sat, Aug 12, 2017 at 11:54 AM, Sue Peters sp@suepeters.com wrote:

The ANOVA function asks for two data files (2 groups) group 1 condition and group 2 condition. So how does this fit with a 2x2 cell array with all of the data (from both groups) in one file? or do I create 2 separate 1x2 cell arrays, or set it as 1 group in the initial viewer/gui, and just upload one data file?

On Sat, Aug 12, 2017 at 11:47 AM, Sue Peters sp@suepeters.com wrote:

Thanks Armand!! =)

On Sat, Aug 12, 2017 at 11:40 AM, Armand Mensen <notifications@github.com

wrote:

I've recently been seeing a lot of problems with things pre-2014b... I think Matlab made a lot of changes to more basic functions after that, and since I usually keep up-to-date with Matlab, it becomes difficult to make sure things are backwards compatible. I have 2014a on another computer for this reason, and I'll try it out there and see if I can get a workaround for these older versions.

If you can get your hands on the newest possible one (I think still 2017a for now), then this should be fine. However, I think even 2014b should make a difference.

In regards to the ANOVA... your data should be structured in a 2 x 2 cell array. So a 6 x 124 x 141 in each cell array just keeping consistent across the dimensions (e.g. gender differences in columns, and age differences in the rows... or the other way, just not mixed).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321988742, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xrEDVtpA5iUx_mMrGT9PE4UC6l77ks5sXceIgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025 <(646)%20337-7025>

www.linkedin.com/in/suepeters

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025 <(646)%20337-7025>

www.linkedin.com/in/suepeters

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

Mensen commented 7 years ago

Re: ANOVA... I should probably redo the initial GUI since the procedure there is not quite clear. However, you could manually create a Data cell array in Matlab itself and then run the command: ept_TFCE_ANOVA(Data, e_loc) and manually put the data through the command line.

I don't get any attachment, but could you send it to my regular email address? (research.mensen (at) gmail...

speters14 commented 7 years ago

Ok, thanks.

On Sat, Aug 12, 2017 at 12:46 PM, Armand Mensen notifications@github.com wrote:

Re: ANOVA... I should probably redo the initial GUI since the procedure there is not quite clear. However, you could manually create a Data cell array in Matlab itself and then run the command: ept_TFCE_ANOVA(Data, e_loc) and manually put the data through the command line.

I don't get any attachment, but could you send it to my regular email address? (research.mensen (at) gmail...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321992254, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xkNoHvxSHDEvyXSsv_pBzSHVk7srks5sXdbUgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

speters14 commented 7 years ago

Thanks for help with ANOVA. It's working, but it's not totally clear to me which are Factor A, Factor B, Level 1 and level 2. My data were organized in the cell array as 3mo, 6mo as columns, and male, female as rows. Based on my experience with the data, it seems that the results make most sense as Factor B, being the age difference. Then Factor A is sex, with level 1, and 2 are males and females. This could make sense based on what I see. But So Factor A comparing males as a group and females as a group (regardless of age): nothing significant there, and that too would make sense.

I'm going to send you a separate email with screenshots. Very interesting, as there is a trend (not significant) in the interaction plot, which matches (topographic and direction) of my earlier analyses done comparing a larger group using TCFE Ttest, at 6mos, across sex. That was the analyses where I changed the E and H values a while back (spring), with justification based on the signal to noise theory, in an infant brain. Hopefully you received that email I sent to you.

Thanks again. =)

On Sat, Aug 12, 2017 at 12:51 PM, Sue Peters sp@suepeters.com wrote:

Ok, thanks.

On Sat, Aug 12, 2017 at 12:46 PM, Armand Mensen notifications@github.com wrote:

Re: ANOVA... I should probably redo the initial GUI since the procedure there is not quite clear. However, you could manually create a Data cell array in Matlab itself and then run the command: ept_TFCE_ANOVA(Data, e_loc) and manually put the data through the command line.

I don't get any attachment, but could you send it to my regular email address? (research.mensen (at) gmail...

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Mensen/ept_TFCE-matlab/issues/8#issuecomment-321992254, or mute the thread https://github.com/notifications/unsubscribe-auth/AHH7xkNoHvxSHDEvyXSsv_pBzSHVk7srks5sXdbUgaJpZM4O0JFm .

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025 <(646)%20337-7025>

www.linkedin.com/in/suepeters

--

Sue Peters PhD Candidate

Infancy Studies Laboratory Facebook: RUBabyLab https://www.facebook.com/RUbabylab/ Center for Molecular and Behavioral Neuroscience Facebook: CMBN https://www.facebook.com/cmbnrutgers/ Rutgers University - Newark sp@suepeters.com mobile: 646-337-7025

www.linkedin.com/in/suepeters

speters14 commented 7 years ago

Back to the correlation. Tried it on another computer, now running Matlab 2017a. It appeared to be working this time until this error appeared. I did install the compiler and run mex -setup. But when installing the compiler there was an option for C++ or Fortran, but I ignored it. Not sure if relevant (see below the error for that Matlab message)

Calculating Channel Neighbours... Done Calculating Actual Differences... Invalid MEX-file 'C:\Users\Sue\Documents\MATLAB\ept_TFCE-matlab-master\TFCE\Dependencies\ept_mex_TFCE2D.mexw64': Missing symbol 'mxErrMsgTxt' in 'C:\Program Files\MATLAB\R2017a/bin/win64\libmx.dll' required by 'C:\Users\Sue\Documents\MATLAB\ept_TFCE-matlab-master\TFCE\Dependencies\ept_mex_TFCE2D.mexw64'.

Error in ept_TFCE (line 354) TFCE_Obs = ept_mex_TFCE2D(T_Obs, ChN, E_H);

end of error msg start of mex message

mex -setup MEX configured to use 'MinGW64 Compiler (C)' for C language compilation. Warning: The MATLAB C and Fortran API has changed to support MATLAB variables with more than 2^32-1 elements. You will be required to update your code to utilize the new API. You can find more information about this at: http://www.mathworks.com/help/matlab/matlab_external/upgrading-mex-files-to-use-64-bit-api.html.

To choose a different language, select one from the following: mex -setup C++ mex -setup FORTRAN

Mensen commented 7 years ago

A note on the ANOVA that is not explicitly made in the scripts... The default h value for ANOVA is 1 since the F-values that are compared are already squared T-values. Just good to know for reporting statistics in case you go into that much detail in the methods sections.


Re the mex issue...

At some point the matlab-mex stuff stopped recognising the command mxErrMsgTxt and instead only recognised mexErrMsgTxt... these were changed in the toolbox ".c" files, but you may need to recompile them on a windows system since the pre-compiled windows files might still have the older "mx" convention.

There's probably no issue with the compiler... but you'll still need to go into the dependencies folder and mex each ".c." file separately unfortunately. I'd be happy to do this for you, but I don't use windows so I can't. However, if you manage to create the new "mexw64" files you could send them to me and I'll include these in an update of the toolbox (or you send me a "pull request" with your toolbox version).

I tested my own correlation scripts with your data, and, as you also now saw, they work with the latest matlab version. However, I saw they were incredibly slow! Hope this is not too annoying. I don't have the time at the moment to go through these another way but will make a note on the TODO list.