Re: [HCP-Users] CIFTI tools in the Python

2017-10-11 Thread Timothy Coalson
Nibabel should support cifti files now, though it may be fairly basic:

https://github.com/nipy/nibabel

I don't know of other projects for cifti in python.

Tim


On Wed, Oct 11, 2017 at 11:18 PM, Aaron Crank 
wrote:

> Dear HCP experts,
>
>
> I have a question about loading CIFTI files in the Python. Would you
> please suggest if there are any well-established tools in the Python to
> work with CIFTI format files? Thank you.
>
>
> ___
> HCP-Users mailing list
> HCP-Users@humanconnectome.org
> http://lists.humanconnectome.org/mailman/listinfo/hcp-users
>

___
HCP-Users mailing list
HCP-Users@humanconnectome.org
http://lists.humanconnectome.org/mailman/listinfo/hcp-users


[HCP-Users] CIFTI tools in the Python

2017-10-11 Thread Aaron Crank
Dear HCP experts,


I have a question about loading CIFTI files in the Python. Would you please 
suggest if there are any well-established tools in the Python to work with 
CIFTI format files? Thank you.


___
HCP-Users mailing list
HCP-Users@humanconnectome.org
http://lists.humanconnectome.org/mailman/listinfo/hcp-users


[HCP-Users] UMN Informatics Institute - Neuroimaging Staff Scientist posting

2017-10-11 Thread bryon mueller
The University of Minnesota Informatics Institute (UMII)
 seeks a skilled, staff scientist to
serve the MR Neuroimaging research community at the University of
Minnesota. The successful candidate is expected to: (1) carry out
consultations with researchers across the University and serve in the role
of a staff scientist who provides technical assistance across multiple
research groups; (2) provide technical and analytic support in designing
and supporting neuroimaging analysis pipelines that will be run on
platforms of the Minnesota Supercomputing Institute (MSI); (3)
appropriately document work so that researchers are able to prepare grants,
research papers and reports based on the analysis; (4) simultaneously
support different versions of analysis tools that might require different
libraries and operating system versions; (5) develop new computational
environments, such as Docker, for major neuroimaging analysis platforms
(AFNI, FSL, etc.) in the HPC environment at MSI; and (6) build
computational workflows that scale and work across a broad range of file
system storage.

The successful candidate will join a growing group of imaging analysts in
the University of Minnesota Informatics Institute. The Imaging Informatics
Manager at the University of Minnesota Informatics Institute will serve as
the supervisor. On a daily basis, the analyst will work closely with MR
neuroimaging researchers, and staff at the Minnesota Supercomputing
Institute.

This position is both posted as a Researcher 5
, Research Scientist (minimum
required qualification: PhD) under Job Opening 319904
 (https://z.umn.edu/umii-neuroi
maging-job-5) and as a Researcher 3
, Assistant Scientist, (minimum
required qualification: Bachelor's degree) under Job Opening 319899
 (https://z.umn.edu/umii-neuroi
maging-job-3).

Qualifications

Required:

• Background in scientific image processing, analysis or multi-dimensional
signal processing

• Have proficiency in at least one programming language (Python, MATLAB,
Java, C++, …)

• Be familiar with the Linux operating system

• Have excellent interpersonal and organizational skills

• Be able to articulate processes verbally and in writing

• Be highly motivated to learn new technical skills

Additional requirements for the Researcher 5 position (Job Opening 319904):

• Doctoral degree in a science or engineering field

• Experience in MR neuroimaging image analysis (fMRI, DWI, or structural)

• Significant research experience and ability to work independently

• Experience working in a team environment with people with diverse
expertise

• Publications, software, or grant applications demonstrating creativity
and independence

Preferred:

• (for Researcher 3 position) Master’s degree in a science or engineering
field

• (for Researcher 3 position) Experience in MR neuroimaging image analysis
(fMRI, DWI, structural)

• (for both positions) Experience in medical image analysis

• (for both positions) Experience with container technology, such as Docker

• (for both positions) Experience in HPC environments

• (for both positions) Experience with neuroimaging analysis software
packages such as FSL, AFNI, SPM

• (for both positions) Experience working in a team environment with people
with diverse expertise

___
HCP-Users mailing list
HCP-Users@humanconnectome.org
http://lists.humanconnectome.org/mailman/listinfo/hcp-users


Re: [HCP-Users] Combining rfMRI data for different phase encoding directions

2017-10-11 Thread Timothy Coalson
It was probably killed because it ran out of memory.  The best solution is
to use a machine with more memory.

A workaround, but one that will take a LOT more time to run on each subject
(unless you happen to already have fast SSDs), is to add swap space to your
system, which will allow it to pretend that it has more memory than it
really does, by writing some data that should be in RAM onto a storage
device (which is orders of magnitude slower than RAM).

Tim


On Wed, Oct 11, 2017 at 10:40 AM, Sang-Young Kim  wrote:

> Dear Matt:
>
> I turned off the array size limit in Matlab, then ran again
> hcp_fix_multi_run. I cannot see any error in .fix.log file but cleaned data
> was not generated. One thing I can notice in the terminal is that some
> process is killed automatically.
> Please see below:
>
> FIX Applying cleanup using cleanup file: rfMRI_REST_All_hp2000.ica/
> fix4melview_HCP_hp2000_thr10.txt and motion cleanup set to 1
> sh: line 1:  7063 Killed: 9   
> /Applications/MATLAB_R2015b.app/bin/matlab
> -nojvm -nodisplay -nodesktop -nosplash -r "restoredefaultpath;
> addpath('/usr/local/fsl/etc/matlab'); addpath('/Users/sang-young/
> projects/Pipelines/global/matlab'); addpath('/usr/local/fix');
> fix_3_clean('.fix',0,1,-1)" >> .fix.log 2>&1
> Start=1 Stop=420
>
> Do you have any idea why this happen and how to fix it?
>
> Many thanks.
>
> Sang-Young
>
>
>
>
> On Oct 9, 2017, at 6:19 PM, Glasser, Matthew  wrote:
>
> I think you will need to go in the matlab preferences and fix that.  I
> don’t recall exactly where it is, but it should be easy to find on google.
> Basically you need to turn off the array size limit.  Alternatively you
> need to run the job on a machine with more RAM.
>
> Peace,
>
> Matt.
>
> From: Sang-Young Kim 
> Date: Monday, October 9, 2017 at 9:58 AM
> To: Matt Glasser 
> Cc: Stephen Smith , "hcp-users@humanconnectome.org"
> 
> Subject: Re: [HCP-Users] Combining rfMRI data for different phase
> encoding directions
>
> Dear Matt:
>
> I ran the multi-run ICA+FIX according to your guideline. But at the last
> stage of cleaning the data (e.g., fix_3_clean), I got an error message in
> the file of .fix.log. Please see below:
>
> Could you please help me how to handle this issue?
>
> Thanks.
>
> Sang-Young
>
> TR =
>
> 0.8000
>
> Elapsed time is 24.545680 seconds.
> Elapsed time is 2.739398 seconds.
> {^HError using '
> Requested 902629x3360 (22.6GB) array exceeds maximum array size preference.
> Creation of arrays greater than this limit may take a long time and cause
> MATLAB to become unresponsive. See array size
> limit
> or preference panel for more information.
>
> Error in fix_3_clean (line 67)
>   cts=reshape(cts,ctsX*ctsY*ctsZ,ctsT)’;
>
>
>
>
>
> On Oct 6, 2017, at 4:40 PM, Glasser, Matthew  wrote:
>
> No multi-run ICA+FIX handles the concatenation for you so you specify the
> separate runs.  That is the whole point.  Have a look at this bioRvix paper
> in the methods about multi-run ICA+FIX so you understand why it is
> implemented the way it is:
>
> https://www.biorxiv.org/content/early/2017/09/27/193862
>
> Here is an example call to multi-run ICA+FIX:
>
> ${FSL_FIXDIR}/hcp_fix_multi_run ${StudyFolder}/${Subject}/
> MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz@$
> {StudyFolder}/${Subject}/MNINonLinear/Results/${
> fMRIName}/${fMRIName}.nii.gz@${StudyFolder}/${Subject}/
> MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz@$
> {StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz
> 2000 ${StudyFolder}/${Subject}/MNINonLinear/Results/${
> ConcatName}/${ConcatName}.nii.gz
>
> Peace,
>
> Matt.
>
> From: Sang-Young Kim 
> Date: Friday, October 6, 2017 at 4:17 PM
> To: Matt Glasser 
> Cc: Stephen Smith , "hcp-users@humanconnectome.org"
> 
> Subject: Re: [HCP-Users] Combining rfMRI data for different phase
> encoding directions
>
> Thanks! Matt!
>
> I have one more following-up question. In order to run the script
> "hcp_fix_multi_run", we have to concatenate all the data temporally, right?
> I combined the data using following command: fslmerge -t
>   ….
>
> Then, I ran the hcp_fix_multi_run script as follow: hcp_fix_multi_run
>  2000 rfMRI_REST_Concat
> ${FSL_FIXDIR}/training_files/HCP_hp2000.RData
> I also tried to input the data as a list file, but the script didn’t work
> with error. It seems to get only one 4D rfMRI data set as input.
> That’s why I concatenated each run of rfMRI data set.
>
> Could you please confirm whether the above procedures are correct or not?
>
> Thanks again.
>
> Sang-Young
>
>
> On Oct 6, 2017, at 3:57 PM, Glasser, Matthew  wrote:
>
> I would not do #2 as you need to do some preprocessing prior to running
> ICA+FIX when concatenating across 

Re: [HCP-Users] Combining rfMRI data for different phase encoding directions

2017-10-11 Thread Sang-Young Kim
Dear Matt:

I turned off the array size limit in Matlab, then ran again hcp_fix_multi_run. 
I cannot see any error in .fix.log file but cleaned data was not generated. One 
thing I can notice in the terminal is that some process is killed 
automatically. 
Please see below:

FIX Applying cleanup using cleanup file: 
rfMRI_REST_All_hp2000.ica/fix4melview_HCP_hp2000_thr10.txt and motion cleanup 
set to 1
sh: line 1:  7063 Killed: 9   
/Applications/MATLAB_R2015b.app/bin/matlab -nojvm -nodisplay -nodesktop 
-nosplash -r "restoredefaultpath; addpath('/usr/local/fsl/etc/matlab'); 
addpath('/Users/sang-young/projects/Pipelines/global/matlab'); 
addpath('/usr/local/fix'); fix_3_clean('.fix',0,1,-1)" >> .fix.log 2>&1
Start=1 Stop=420

Do you have any idea why this happen and how to fix it?

Many thanks. 

Sang-Young

 


> On Oct 9, 2017, at 6:19 PM, Glasser, Matthew  wrote:
> 
> I think you will need to go in the matlab preferences and fix that.  I don’t 
> recall exactly where it is, but it should be easy to find on google.  
> Basically you need to turn off the array size limit.  Alternatively you need 
> to run the job on a machine with more RAM.
> 
> Peace,
> 
> Matt.
> 
> From: Sang-Young Kim >
> Date: Monday, October 9, 2017 at 9:58 AM
> To: Matt Glasser >
> Cc: Stephen Smith >, 
> "hcp-users@humanconnectome.org " 
> >
> Subject: Re: [HCP-Users] Combining rfMRI data for different phase encoding 
> directions
> 
> Dear Matt:
> 
> I ran the multi-run ICA+FIX according to your guideline. But at the last 
> stage of cleaning the data (e.g., fix_3_clean), I got an error message in the 
> file of .fix.log. Please see below:
> 
> Could you please help me how to handle this issue?
> 
> Thanks. 
> 
> Sang-Young
> 
> TR =
> 
> 0.8000
> 
> Elapsed time is 24.545680 seconds.
> Elapsed time is 2.739398 seconds.
> {^HError using '
> Requested 902629x3360 (22.6GB) array exceeds maximum array size preference.
> Creation of arrays greater than this limit may take a long time and cause
> MATLAB to become unresponsive. See array size 
> limit
> or preference panel for more information.
> 
> Error in fix_3_clean (line 67)
>   cts=reshape(cts,ctsX*ctsY*ctsZ,ctsT)’;
> 
> 
> 
> 
> 
>> On Oct 6, 2017, at 4:40 PM, Glasser, Matthew > > wrote:
>> 
>> No multi-run ICA+FIX handles the concatenation for you so you specify the 
>> separate runs.  That is the whole point.  Have a look at this bioRvix paper 
>> in the methods about multi-run ICA+FIX so you understand why it is 
>> implemented the way it is:
>> 
>> https://www.biorxiv.org/content/early/2017/09/27/193862 
>>  
>> 
>> Here is an example call to multi-run ICA+FIX:
>> 
>> ${FSL_FIXDIR}/hcp_fix_multi_run 
>> ${StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz@${StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz@${StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz@${StudyFolder}/${Subject}/MNINonLinear/Results/${fMRIName}/${fMRIName}.nii.gz
>>  2000 
>> ${StudyFolder}/${Subject}/MNINonLinear/Results/${ConcatName}/${ConcatName}.nii.gz
>> 
>> Peace,
>> 
>> Matt.
>> 
>> From: Sang-Young Kim >
>> Date: Friday, October 6, 2017 at 4:17 PM
>> To: Matt Glasser >
>> Cc: Stephen Smith >, 
>> "hcp-users@humanconnectome.org " 
>> >
>> Subject: Re: [HCP-Users] Combining rfMRI data for different phase encoding 
>> directions
>> 
>> Thanks! Matt!
>> 
>> I have one more following-up question. In order to run the script 
>> "hcp_fix_multi_run", we have to concatenate all the data temporally, right?
>> I combined the data using following command: fslmerge -t  
>>  …. 
>> 
>> Then, I ran the hcp_fix_multi_run script as follow: hcp_fix_multi_run 
>>  2000 rfMRI_REST_Concat 
>> ${FSL_FIXDIR}/training_files/HCP_hp2000.RData
>> I also tried to input the data as a list file, but the script didn’t work 
>> with error. It seems to get only one 4D rfMRI data set as input. 
>> That’s why I concatenated each run of rfMRI data set. 
>> 
>> Could you please confirm whether the above procedures are correct or not?
>> 
>> Thanks again. 
>> 
>> Sang-Young
>>  
>> 
>>> On Oct 6, 2017, at 3:57 PM, Glasser, Matthew >> > wrote:
>>> 
>>> I would not do #2 as you need to do some preprocessing prior to running 
>>> ICA+FIX when concatenating across runs and this 

Re: [HCP-Users] eravg for MEG Working memory dataset for face condition

2017-10-11 Thread Jean-Didier Lemarechal
yes I guess you are right, it looks like all files are organized into 
subdirectories at the end of the pipeline using hcp_megrelease.sh


so it should work like that :)

thanks again

jd


Le 11/10/2017 à 16:56, Georgios Michalareas a écrit :


I think as long as these files are in the MATLAB path

the pipelines should work

so you just have to the matlab path the directory where they are or 
always work in this directory i guess




On 10/11/2017 4:23 PM, Jean-Didier Lemarechal wrote:


waouh !!! thank you so much for this clear and detailled help...


I used the same idea as you proposed with a contrastList and the 
script hcp_eravg_contrasts.m (to try to keep in line with the 
pipeline philosophy...)



because the next thing I would like to do is the source localization 
of these new ERF :)



And there comes my new rather practical question:


For hcp_eravg_contrasts.m to find the files 
'177746_MEG_6-Wrkmem_tmegpreproc_TIM', 
'177746_MEG_6-Wrkmem_tmegpreproc_trialinfo', ..., I had to be in the 
directory containing them :



177746/MEG/Wrkmem


and all the averaged output files ( *.mat, *.png, *xml ) were 
therefore  generated in this directory , instead of



177746/MEG/eravg

177746/MEG/eravg/figures

177746/MEG/eravg/provenance


Will this be a problem for the following source localization step ?


Should I write a few matlab lines to move the generated files in the 
"expected" directories ? Or maybe there is an appropriate way to call 
hcp_eravg_contrasts.m to do this automatically ?



Many thanks anyway !!

JD


Le 11/10/2017 à 15:20, Georgios Michalareas a écrit :


Hi Jean-Didier,

If you need a subset of 0-Back i.e. Faces you ll have to compute the 
average yourself . The way to do it to load the cleaned prerocessed 
data for specific subject :


i.e.


load ('load 177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

and also load the single trial information

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');


The trlInfo Contains:


trlInfo =

  lockNames: {'TIM'  'TRESP'}
    lockTrl: {[187x40 double]  [186x40 double]}
    trlColDescr: {{40x1 cell}  {40x1 cell}}


the trial information is in field    .lockTrl

so if you want to load the trials cut relative to the Image onset 
(TIM) , then



trialinfo=trlInfo.lockTrl{1};


This is a matrix with dimension Ntrials x 40 .

The description of each column can be found in


trlInfo.trlColDescr{1}


as you will see in there, columns 4 and 5 have info for image type 
and memory Type,



 '4. imgType : 1- Face, 2- Tools  0- Fixation'
  '5. memoryType :  1: 0-Back   2: 2-Back'


So if you want 0-back faces you need to find all trials for which 
column 4 is equal to 1 and column 5 is equal to 1



indIn=find((trialinfo(:,4)==1)&(trialinfo(:,5)==1));

Now you need the indices of the trials you need to select from the 
'data' variable.


the data variable contains



data =

  hdr: [1x1 struct]
  fsample: 508.6275
    trialinfo: [186x40 double]
 grad: [1x1 struct]
    trial: {1x186 cell}
 time: {1x186 cell}
    label: {244x1 cell}
  cfg: [1x1 struct]


the actual single trial data is in field .trial.

so the the trial data for 0-bak faces is

data.trial{indIn}.


If you have fieldtrip toolbox and you wanna retain the data 
structure in fieldtrip format you can extract the 0-back Faces trials by



data_0B_face=ft_select_data(data,'rpt',indIn);


'rpt' stands for repetitions aka trials



Please keep in mind that Working memory has two runs and the 
preprocessed data is released for each run separately so you need to 
do the above for each run.


I have put some MATcode below that should give you the average for 
0-back faces



%==
%Run 1

load ('177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run1=data;

trialinfo_run1=trlInfo.lockTrl{1};

indIn_run1=find((trialinfo_run1(:,4)==1)&(trialinfo_run1(:,5)==1));


%Run 2

load ('177746_MEG_7-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_7-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run2=data;

trialinfo_run2=trlInfo.lockTrl{1};

indIn_run2=find((trialinfo_run2(:,4)==1)&(trialinfo_run2(:,5)==1));



data_0B_face_run1=ft_selectdata(data_run1,'rpt',indIn_run1);

data_0B_face_run2=ft_selectdata(data_run2,'rpt',indIn_run2);

% Find Common channels
common_channels=intersect(data_0B_face_run1.label,data_0B_face_run2.label);
% Select common channels from each run
data_0B_face_run1=ft_selectdata(data_0B_face_run1,'channel',common_channels);
data_0B_face_run2=ft_selectdata(data_0B_face_run2,'channel',common_channels);

% Append the two runs
data_0B_face=ft_appenddata([], data_0B_face_run1,data_0B_face_run2);

% Demean from baseline before Averaging trials
cfg=[];
cfg.demean='yes';
cfg.baselinewindow = [-0.55 -0.05];
tmpdata=ft_preprocessing(cfg,data_0B_face);

% Average
cfg=[];

Re: [HCP-Users] eravg for MEG Working memory dataset for face condition

2017-10-11 Thread Georgios Michalareas

I think as long as these files are in the MATLAB path

the pipelines should work

so you just have to the matlab path the directory where they are or 
always work in this directory i guess




On 10/11/2017 4:23 PM, Jean-Didier Lemarechal wrote:


waouh !!! thank you so much for this clear and detailled help...


I used the same idea as you proposed with a contrastList and the 
script hcp_eravg_contrasts.m (to try to keep in line with the pipeline 
philosophy...)



because the next thing I would like to do is the source localization 
of these new ERF :)



And there comes my new rather practical question:


For hcp_eravg_contrasts.m to find the files 
'177746_MEG_6-Wrkmem_tmegpreproc_TIM', 
'177746_MEG_6-Wrkmem_tmegpreproc_trialinfo', ..., I had to be in the 
directory containing them :



177746/MEG/Wrkmem


and all the averaged output files ( *.mat, *.png, *xml ) were 
therefore  generated in this directory , instead of



177746/MEG/eravg

177746/MEG/eravg/figures

177746/MEG/eravg/provenance


Will this be a problem for the following source localization step ?


Should I write a few matlab lines to move the generated files in the 
"expected" directories ? Or maybe there is an appropriate way to call 
hcp_eravg_contrasts.m to do this automatically ?



Many thanks anyway !!

JD


Le 11/10/2017 à 15:20, Georgios Michalareas a écrit :


Hi Jean-Didier,

If you need a subset of 0-Back i.e. Faces you ll have to compute the 
average yourself . The way to do it to load the cleaned prerocessed 
data for specific subject :


i.e.


load ('load 177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

and also load the single trial information

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');


The trlInfo Contains:


trlInfo =

  lockNames: {'TIM'  'TRESP'}
    lockTrl: {[187x40 double]  [186x40 double]}
    trlColDescr: {{40x1 cell}  {40x1 cell}}


the trial information is in field    .lockTrl

so if you want to load the trials cut relative to the Image onset 
(TIM) , then



trialinfo=trlInfo.lockTrl{1};


This is a matrix with dimension Ntrials x 40 .

The description of each column can be found in


trlInfo.trlColDescr{1}


as you will see in there, columns 4 and 5 have info for image type 
and memory Type,



 '4. imgType : 1- Face, 2- Tools  0- Fixation'
  '5. memoryType :  1: 0-Back   2: 2-Back'


So if you want 0-back faces you need to find all trials for which 
column 4 is equal to 1 and column 5 is equal to 1



indIn=find((trialinfo(:,4)==1)&(trialinfo(:,5)==1));

Now you need the indices of the trials you need to select from the 
'data' variable.


the data variable contains



data =

  hdr: [1x1 struct]
  fsample: 508.6275
    trialinfo: [186x40 double]
 grad: [1x1 struct]
    trial: {1x186 cell}
 time: {1x186 cell}
    label: {244x1 cell}
  cfg: [1x1 struct]


the actual single trial data is in field .trial.

so the the trial data for 0-bak faces is

data.trial{indIn}.


If you have fieldtrip toolbox and you wanna retain the data structure 
in fieldtrip format you can extract the 0-back Faces trials by



data_0B_face=ft_select_data(data,'rpt',indIn);


'rpt' stands for repetitions aka trials



Please keep in mind that Working memory has two runs and the 
preprocessed data is released for each run separately so you need to 
do the above for each run.


I have put some MATcode below that should give you the average for 
0-back faces



%==
%Run 1

load ('177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run1=data;

trialinfo_run1=trlInfo.lockTrl{1};

indIn_run1=find((trialinfo_run1(:,4)==1)&(trialinfo_run1(:,5)==1));


%Run 2

load ('177746_MEG_7-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_7-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run2=data;

trialinfo_run2=trlInfo.lockTrl{1};

indIn_run2=find((trialinfo_run2(:,4)==1)&(trialinfo_run2(:,5)==1));



data_0B_face_run1=ft_selectdata(data_run1,'rpt',indIn_run1);

data_0B_face_run2=ft_selectdata(data_run2,'rpt',indIn_run2);

% Find Common channels
common_channels=intersect(data_0B_face_run1.label,data_0B_face_run2.label);
% Select common channels from each run
data_0B_face_run1=ft_selectdata(data_0B_face_run1,'channel',common_channels);
data_0B_face_run2=ft_selectdata(data_0B_face_run2,'channel',common_channels);

% Append the two runs
data_0B_face=ft_appenddata([], data_0B_face_run1,data_0B_face_run2);

% Demean from baseline before Averaging trials
cfg=[];
cfg.demean='yes';
cfg.baselinewindow = [-0.55 -0.05];
tmpdata=ft_preprocessing(cfg,data_0B_face);

% Average
cfg=[];
tmpavg=ft_timelockanalysis(cfg,tmpdata);

% Visualize the average
cfg=[];
cfg.layout='4D248.lay';
ft_multiplotER(cfg,tmpavg);
%---
% All the Fieldtrip commands require Fieldtrip toolbox.
% After you 

Re: [HCP-Users] eravg for MEG Working memory dataset for face condition

2017-10-11 Thread Jean-Didier Lemarechal

waouh !!! thank you so much for this clear and detailled help...


I used the same idea as you proposed with a contrastList and the script 
hcp_eravg_contrasts.m (to try to keep in line with the pipeline 
philosophy...)



because the next thing I would like to do is the source localization of 
these new ERF :)



And there comes my new rather practical question:


For hcp_eravg_contrasts.m to find the files 
'177746_MEG_6-Wrkmem_tmegpreproc_TIM', 
'177746_MEG_6-Wrkmem_tmegpreproc_trialinfo', ..., I had to be in the 
directory containing them :



177746/MEG/Wrkmem


and all the averaged output files ( *.mat, *.png, *xml ) were therefore  
generated in this directory , instead of



177746/MEG/eravg

177746/MEG/eravg/figures

177746/MEG/eravg/provenance


Will this be a problem for the following source localization step ?


Should I write a few matlab lines to move the generated files in the 
"expected" directories ? Or maybe there is an appropriate way to call 
hcp_eravg_contrasts.m to do this automatically ?



Many thanks anyway !!

JD


Le 11/10/2017 à 15:20, Georgios Michalareas a écrit :


Hi Jean-Didier,

If you need a subset of 0-Back i.e. Faces you ll have to compute the 
average yourself . The way to do it to load the cleaned prerocessed 
data for specific subject :


i.e.


load ('load 177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

and also load the single trial information

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');


The trlInfo Contains:


trlInfo =

  lockNames: {'TIM'  'TRESP'}
    lockTrl: {[187x40 double]  [186x40 double]}
    trlColDescr: {{40x1 cell}  {40x1 cell}}


the trial information is in field    .lockTrl

so if you want to load the trials cut relative to the Image onset 
(TIM) , then



trialinfo=trlInfo.lockTrl{1};


This is a matrix with dimension Ntrials x 40 .

The description of each column can be found in


trlInfo.trlColDescr{1}


as you will see in there, columns 4 and 5 have info for image type and 
memory Type,



 '4. imgType : 1- Face, 2- Tools  0- Fixation'
  '5. memoryType :  1: 0-Back   2: 2-Back'


So if you want 0-back faces you need to find all trials for which 
column 4 is equal to 1 and column 5 is equal to 1



indIn=find((trialinfo(:,4)==1)&(trialinfo(:,5)==1));

Now you need the indices of the trials you need to select from the 
'data' variable.


the data variable contains



data =

  hdr: [1x1 struct]
  fsample: 508.6275
    trialinfo: [186x40 double]
 grad: [1x1 struct]
    trial: {1x186 cell}
 time: {1x186 cell}
    label: {244x1 cell}
  cfg: [1x1 struct]


the actual single trial data is in field .trial.

so the the trial data for 0-bak faces is

data.trial{indIn}.


If you have fieldtrip toolbox and you wanna retain the data structure 
in fieldtrip format you can extract the 0-back Faces trials by



data_0B_face=ft_select_data(data,'rpt',indIn);


'rpt' stands for repetitions aka trials



Please keep in mind that Working memory has two runs and the 
preprocessed data is released for each run separately so you need to 
do the above for each run.


I have put some MATcode below that should give you the average for 
0-back faces



%==
%Run 1

load ('177746_MEG_6-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_6-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run1=data;

trialinfo_run1=trlInfo.lockTrl{1};

indIn_run1=find((trialinfo_run1(:,4)==1)&(trialinfo_run1(:,5)==1));


%Run 2

load ('177746_MEG_7-Wrkmem_tmegpreproc_TIM','data');

load ('177746_MEG_7-Wrkmem_tmegpreproc_trialinfo','trlInfo');

data_run2=data;

trialinfo_run2=trlInfo.lockTrl{1};

indIn_run2=find((trialinfo_run2(:,4)==1)&(trialinfo_run2(:,5)==1));



data_0B_face_run1=ft_selectdata(data_run1,'rpt',indIn_run1);

data_0B_face_run2=ft_selectdata(data_run2,'rpt',indIn_run2);

% Find Common channels
common_channels=intersect(data_0B_face_run1.label,data_0B_face_run2.label);
% Select common channels from each run
data_0B_face_run1=ft_selectdata(data_0B_face_run1,'channel',common_channels);
data_0B_face_run2=ft_selectdata(data_0B_face_run2,'channel',common_channels);

% Append the two runs
data_0B_face=ft_appenddata([], data_0B_face_run1,data_0B_face_run2);

% Demean from baseline before Averaging trials
cfg=[];
cfg.demean='yes';
cfg.baselinewindow = [-0.55 -0.05];
tmpdata=ft_preprocessing(cfg,data_0B_face);

% Average
cfg=[];
tmpavg=ft_timelockanalysis(cfg,tmpdata);

% Visualize the average
cfg=[];
cfg.layout='4D248.lay';
ft_multiplotER(cfg,tmpavg);
%---
% All the Fieldtrip commands require Fieldtrip toolbox.
% After you download it in a folder ,i.e. /home/username/fieldtrip
% you can add it to the path with the following commands

% addpath('/home/username/fieldtrip');
% ft_defaults;
%==