Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-15 Thread K Jeffrey Eriksen
Georgos,

I finally have one bit of progress here. The latest FieldTrip installed OK and 
I was able to use the ft_read_mri function to read the T1 
(T1w_acpc_dc_restore.nii) that comes out of the standard HCP pipeline. It 
showed this transform:
-10  0  91
0  1  0  -127
0  0  1  -73
0  0  0  1
Which I presume is the equivalent of the vox2spm transform, one of the two I 
need for Brainstorm. I am showing my ignorance and inexperience here, but I 
thought the [load_nii.m] I obtained elsewhere and use to load this T1 would 
give the same (and complete) contents of the T1.nii file. I also thought that 
[ft_read_mri.m] would show the exact same contents as the load_nii.m script. 
But such is not the case. Different fields are output, though I can see the 
contents of the transform in the load_nii version in the s_row_x,y,z vectors.

I still need the second transform, vox2bti, which in my case would be something 
like vox2EGI for the EGI Net Station electrode coordinates, expressed in some 
head coordinate system. In the HCP-MEG pipeline the vox2bti transform must be 
created by registering the BTI MEG sensor coordinates to the voxels, which also 
must utilize the AC location that is somehow marked on the T1. So it seems to 
me if I could find out where in the HCP-MEG pipeline this is done I could try 
to recreate that for me EEG case by substituting the electrode coordinates.

Can you guide me to someone who might be able to advise me on this aspect of 
the HCP-MEG pipeline?

Thanks,
-Jeff





From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 6:00 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi ,
try using the latest fieldtrip version from
https://github.com/fieldtrip/fieldtrip
maybe it will solve the issue you have.

The T1 file should have a transformation matrix converting voxel indices to 
actual spatial coordinates.
Maybe you can ask the person operating the MR where the T1 comes from
Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Wednesday, February 15, 2017 1:58 AM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Hi again,

Back again to what you wrote:

**
The transformation matrix that goes into field
transform.vox07mm2spm
can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
**

There is no nii file as the above to match the txt file of the same name. The 
only nii file I get in the example is this:
T1_acpc_dc_restore.nii.gz

I have opened this with (load_nii.m) and it has no transforms in it. So I 
remain confused.

(I have tried to use ft_read_mri but it is missing some dlls and I have asked 
FieldTrip support about this. But I do not believe there are any transforms in 
the T1 file I am given)

-Jeff


From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 3:03 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi Jeff,
there no need to run the HCP-MEG pipeline on your anatomical file. I am not 
sure f you can even do this if you also dont have the MEG head positioning 
information.
You can use the fieldtrip function ft_read_mri to read the MRI file you have. 
This function outputs a structure and one of the fields is the transformation 
matrix you are looking for.


Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Tuesday, February 14, 2017 9:52 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgos,

Thank you for continuing to help me on this.

You indicate that 'transform.vox07mm2spm' can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the 'spm to bti' transform, I think that is 

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread Michalareas, Giorgos
Hi ,
try using the latest fieldtrip version from
https://github.com/fieldtrip/fieldtrip
maybe it will solve the issue you have.

The T1 file should have a transformation matrix converting voxel indices to 
actual spatial coordinates.
Maybe you can ask the person operating the MR where the T1 comes from
Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Wednesday, February 15, 2017 1:58 AM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi again,

Back again to what you wrote:

**
The transformation matrix that goes into field
transform.vox07mm2spm
can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
**

There is no nii file as the above to match the txt file of the same name. The 
only nii file I get in the example is this:
T1_acpc_dc_restore.nii.gz

I have opened this with (load_nii.m) and it has no transforms in it. So I 
remain confused.

(I have tried to use ft_read_mri but it is missing some dlls and I have asked 
FieldTrip support about this. But I do not believe there are any transforms in 
the T1 file I am given)

-Jeff


From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 3:03 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi Jeff,
there no need to run the HCP-MEG pipeline on your anatomical file. I am not 
sure f you can even do this if you also dont have the MEG head positioning 
information.
You can use the fieldtrip function ft_read_mri to read the MRI file you have. 
This function outputs a structure and one of the fields is the transformation 
matrix you are looking for.


Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Tuesday, February 14, 2017 9:52 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgos,

Thank you for continuing to help me on this.

You indicate that ‘transform.vox07mm2spm’ can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the ‘spm to bti’ transform, I think that is mainly to register the 
MEG sensors to everything else. In my case the positons of the EEG sensors are 
given in native MRI space. I will ask Brainstorm people for more help with this 
part as I think they should definitely know how to calculate this.

-Jeff

From: Georgios Michalareas [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 12:56 AM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Hi Jeffey,

regarding:

" So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. "
The transformation matrix that goes into field

transform.vox07mm2spm

can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
by using the function ft_read_mri from fieldtrip toolbox.

As you don't have any MEG coordinate system and only the MRI coordinate system 
then there is no transformation from "spm" to "bti". They are the same 
coordinate system in your case. In the example from BS they used the 
transform.txt file from a subject with MEG. In this case there was a different 
MEG coordinate system that is why the two transformation matrices were not 
identical.

the simplest way to create your own transform.txt file is by using the function
hcp_write_ascii from the MEG pipeline code that you can download in 
ConnectomeDB("megconnectome").

transform =[];
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
]; % This is the transformation matrix you read with ft_read_mri from the 
processed MRI file

transform.vox07mm2bti =vox07mm2spm;
transformfile=_MEG_anatomy_transform.txt
hcp_write_ascii (transformfile,'transform');


Best
Giorgos

On 2/14/2017 12:41 AM, K Jeffrey Eriksen wrote:
Georgos,

Understood about the

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread K Jeffrey Eriksen
Hi again,

Back again to what you wrote:

**
The transformation matrix that goes into field
transform.vox07mm2spm
can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
**

There is no nii file as the above to match the txt file of the same name. The 
only nii file I get in the example is this:
T1_acpc_dc_restore.nii.gz

I have opened this with (load_nii.m) and it has no transforms in it. So I 
remain confused.

(I have tried to use ft_read_mri but it is missing some dlls and I have asked 
FieldTrip support about this. But I do not believe there are any transforms in 
the T1 file I am given)

-Jeff


From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 3:03 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi Jeff,
there no need to run the HCP-MEG pipeline on your anatomical file. I am not 
sure f you can even do this if you also dont have the MEG head positioning 
information.
You can use the fieldtrip function ft_read_mri to read the MRI file you have. 
This function outputs a structure and one of the fields is the transformation 
matrix you are looking for.


Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Tuesday, February 14, 2017 9:52 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgos,

Thank you for continuing to help me on this.

You indicate that 'transform.vox07mm2spm' can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the 'spm to bti' transform, I think that is mainly to register the 
MEG sensors to everything else. In my case the positons of the EEG sensors are 
given in native MRI space. I will ask Brainstorm people for more help with this 
part as I think they should definitely know how to calculate this.

-Jeff

From: Georgios Michalareas [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 12:56 AM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Hi Jeffey,

regarding:

" So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. "
The transformation matrix that goes into field

transform.vox07mm2spm

can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
by using the function ft_read_mri from fieldtrip toolbox.

As you don't have any MEG coordinate system and only the MRI coordinate system 
then there is no transformation from "spm" to "bti". They are the same 
coordinate system in your case. In the example from BS they used the 
transform.txt file from a subject with MEG. In this case there was a different 
MEG coordinate system that is why the two transformation matrices were not 
identical.

the simplest way to create your own transform.txt file is by using the function
hcp_write_ascii from the MEG pipeline code that you can download in 
ConnectomeDB("megconnectome").

transform =[];
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
]; % This is the transformation matrix you read with ft_read_mri from the 
processed MRI file

transform.vox07mm2bti =vox07mm2spm;
transformfile=_MEG_anatomy_transform.txt
hcp_write_ascii (transformfile,'transform');


Best
Giorgos

On 2/14/2017 12:41 AM, K Jeffrey Eriksen wrote:
Georgos,

Understood about the naming.

Next question: I have found the Brainstorm code that reads the transform file:

%% = MRI=>MNI TRANSFORMATION =
% Convert transformations from "Brainstorm MRI" to "FieldTrip voxel"
Tbst2ft = [diag([-1, 1, 1] ./ sMri.Voxsize), [size(sMri.Cube,1); 0; 0]; 0 0 0 
1];
% Set the MNI=>SCS transformation in the MRI
Tmni = transform.vox07mm2spm * Tbst2ft;
sMri.NCS.R = Tmni(1:3,1:3);
sMri.NCS.T = Tmni(1:3,4);
% MNI coordinates for the AC/PC/IH fiducials
AC = [0,   3,  -4] ./ 1000;
PC = [0, -25,  -2] ./ 1000;

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread K Jeffrey Eriksen
Never mind, I see on the FT site that all the MEX files may not be available 
for all platforms. I need to compile them for my particular combo of OS+Matlab. 
I will investigate this with local help.

-Jeff

From: hcp-users-boun...@humanconnectome.org 
[mailto:hcp-users-boun...@humanconnectome.org] On Behalf Of K Jeffrey Eriksen
Sent: Tuesday, February 14, 2017 3:42 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt

Giorgos,

I have installed the FieldTrip toolbox associated with megconnectome 3.0, that 
is fieldtrip-r10442. I set the path as per the instructions on the FT site, and 
ran the ft_defaults. When I try to call ft_read_mri, I get this:

filename = T1w_acpc_dc_restore.nii
>> [mri]=ft_read_mri(filename);
Invalid MEX-file
'J:\Projects\HCP_MEG\fieldtrip-r10442\fileio\private\ft_getopt.mexw64':
The specified procedure could not be found..
Error in ft_read_mri (line 79)
mriformat = ft_getopt(varargin, 'dataformat');

I suppose I have not set up the MEX-files properly, but I do not know how to do 
that.
-Jeff

From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 3:03 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi Jeff,
there no need to run the HCP-MEG pipeline on your anatomical file. I am not 
sure f you can even do this if you also dont have the MEG head positioning 
information.
You can use the fieldtrip function ft_read_mri to read the MRI file you have. 
This function outputs a structure and one of the fields is the transformation 
matrix you are looking for.


Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Tuesday, February 14, 2017 9:52 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgos,

Thank you for continuing to help me on this.

You indicate that 'transform.vox07mm2spm' can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the 'spm to bti' transform, I think that is mainly to register the 
MEG sensors to everything else. In my case the positons of the EEG sensors are 
given in native MRI space. I will ask Brainstorm people for more help with this 
part as I think they should definitely know how to calculate this.

-Jeff

From: Georgios Michalareas [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 12:56 AM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Hi Jeffey,

regarding:

" So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. "
The transformation matrix that goes into field

transform.vox07mm2spm

can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
by using the function ft_read_mri from fieldtrip toolbox.

As you don't have any MEG coordinate system and only the MRI coordinate system 
then there is no transformation from "spm" to "bti". They are the same 
coordinate system in your case. In the example from BS they used the 
transform.txt file from a subject with MEG. In this case there was a different 
MEG coordinate system that is why the two transformation matrices were not 
identical.

the simplest way to create your own transform.txt file is by using the function
hcp_write_ascii from the MEG pipeline code that you can download in 
ConnectomeDB("megconnectome").

transform =[];
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
]; % This is the transformation matrix you read with ft_read_mri from the 
processed MRI file

transform.vox07mm2bti =vox07mm2spm;
transformfile=_MEG_anatomy_transform.txt
hcp_write_ascii (transformfile,'transform');


Best
Giorgos
On 2/14/2017 12:41 AM, K Jeffrey Eriksen wrote:
Georgos,

Understood about the naming.

Next question: I have found the Brainstorm code that reads the transform file:

%% = MRI=>MNI TRANSFORMATION =
% Convert transformations from "Brainstorm MRI" to "F

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread K Jeffrey Eriksen
Giorgos,

I have installed the FieldTrip toolbox associated with megconnectome 3.0, that 
is fieldtrip-r10442. I set the path as per the instructions on the FT site, and 
ran the ft_defaults. When I try to call ft_read_mri, I get this:

filename = T1w_acpc_dc_restore.nii
>> [mri]=ft_read_mri(filename);
Invalid MEX-file
'J:\Projects\HCP_MEG\fieldtrip-r10442\fileio\private\ft_getopt.mexw64':
The specified procedure could not be found..
Error in ft_read_mri (line 79)
mriformat = ft_getopt(varargin, 'dataformat');

I suppose I have not set up the MEX-files properly, but I do not know how to do 
that.
-Jeff

From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 3:03 PM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

Hi Jeff,
there no need to run the HCP-MEG pipeline on your anatomical file. I am not 
sure f you can even do this if you also dont have the MEG head positioning 
information.
You can use the fieldtrip function ft_read_mri to read the MRI file you have. 
This function outputs a structure and one of the fields is the transformation 
matrix you are looking for.


Best
Giorgos



From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Tuesday, February 14, 2017 9:52 PM
To: Michalareas, Giorgos
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgos,

Thank you for continuing to help me on this.

You indicate that 'transform.vox07mm2spm' can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the 'spm to bti' transform, I think that is mainly to register the 
MEG sensors to everything else. In my case the positons of the EEG sensors are 
given in native MRI space. I will ask Brainstorm people for more help with this 
part as I think they should definitely know how to calculate this.

-Jeff

From: Georgios Michalareas [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 12:56 AM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Hi Jeffey,

regarding:

" So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. "
The transformation matrix that goes into field

transform.vox07mm2spm

can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
by using the function ft_read_mri from fieldtrip toolbox.

As you don't have any MEG coordinate system and only the MRI coordinate system 
then there is no transformation from "spm" to "bti". They are the same 
coordinate system in your case. In the example from BS they used the 
transform.txt file from a subject with MEG. In this case there was a different 
MEG coordinate system that is why the two transformation matrices were not 
identical.

the simplest way to create your own transform.txt file is by using the function
hcp_write_ascii from the MEG pipeline code that you can download in 
ConnectomeDB("megconnectome").

transform =[];
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
]; % This is the transformation matrix you read with ft_read_mri from the 
processed MRI file

transform.vox07mm2bti =vox07mm2spm;
transformfile=_MEG_anatomy_transform.txt
hcp_write_ascii (transformfile,'transform');


Best
Giorgos

On 2/14/2017 12:41 AM, K Jeffrey Eriksen wrote:
Georgos,

Understood about the naming.

Next question: I have found the Brainstorm code that reads the transform file:

%% = MRI=>MNI TRANSFORMATION =
% Convert transformations from "Brainstorm MRI" to "FieldTrip voxel"
Tbst2ft = [diag([-1, 1, 1] ./ sMri.Voxsize), [size(sMri.Cube,1); 0; 0]; 0 0 0 
1];
% Set the MNI=>SCS transformation in the MRI
Tmni = transform.vox07mm2spm * Tbst2ft;
sMri.NCS.R = Tmni(1:3,1:3);
sMri.NCS.T = Tmni(1:3,4);
% MNI coordinates for the AC/PC/IH fiducials
AC = [0,   3,  -4] ./ 1000;
PC = [0, -25,  -2] ./ 1000;
IH = [0, -10,  60] ./ 1000;
Origin = [0, 0, 0];
% Convert: MNI (meters) => MRI (millimeters)
sMri.NCS.AC = cs_convert(sMri, 'mni', 'mri', AC) .* 1000;
sMri.NCS.PC = cs_

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread K Jeffrey Eriksen
Georgos,

Thank you for continuing to help me on this.

You indicate that 'transform.vox07mm2spm' can be read from the 
'_MEG_anatomy_anatomical.nii' file. Trouble is, I do not have any such 
equivalent files for the data sets I work with, as they are not run through the 
HCP-MEG pipeline. So I do not see how this is relevant to my case. What I need 
is an HCP-EEG pipeline.

My thinking right now is that if I could understand the anatomy part of the 
HCP-MEG pipeline I could apply that part to my generic HCP files to get this 
transform. It just seems to be a registration with an SMP atlas of some sort, 
correct? Could you help me find out where this happens in the HCP-MEG pipeline, 
or direct me to people who have a good understanding of it?

Regarding the 'spm to bti' transform, I think that is mainly to register the 
MEG sensors to everything else. In my case the positons of the EEG sensors are 
given in native MRI space. I will ask Brainstorm people for more help with this 
part as I think they should definitely know how to calculate this.

-Jeff

From: Georgios Michalareas [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Tuesday, February 14, 2017 12:56 AM
To: K Jeffrey Eriksen
Cc: hcp-users@humanconnectome.org
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Hi Jeffey,

regarding:

" So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. "
The transformation matrix that goes into field

transform.vox07mm2spm

can be read from the processed MRI anatomical file , i.e. 
'175237_MEG_anatomy_anatomical.nii'
by using the function ft_read_mri from fieldtrip toolbox.

As you don't have any MEG coordinate system and only the MRI coordinate system 
then there is no transformation from "spm" to "bti". They are the same 
coordinate system in your case. In the example from BS they used the 
transform.txt file from a subject with MEG. In this case there was a different 
MEG coordinate system that is why the two transformation matrices were not 
identical.

the simplest way to create your own transform.txt file is by using the function
hcp_write_ascii from the MEG pipeline code that you can download in 
ConnectomeDB("megconnectome").

transform =[];
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
]; % This is the transformation matrix you read with ft_read_mri from the 
processed MRI file


transform.vox07mm2bti =vox07mm2spm;
transformfile=_MEG_anatomy_transform.txt
hcp_write_ascii (transformfile,'transform');


Best
Giorgos


On 2/14/2017 12:41 AM, K Jeffrey Eriksen wrote:
Georgos,

Understood about the naming.

Next question: I have found the Brainstorm code that reads the transform file:

%% = MRI=>MNI TRANSFORMATION =
% Convert transformations from "Brainstorm MRI" to "FieldTrip voxel"
Tbst2ft = [diag([-1, 1, 1] ./ sMri.Voxsize), [size(sMri.Cube,1); 0; 0]; 0 0 0 
1];
% Set the MNI=>SCS transformation in the MRI
Tmni = transform.vox07mm2spm * Tbst2ft;
sMri.NCS.R = Tmni(1:3,1:3);
sMri.NCS.T = Tmni(1:3,4);
% MNI coordinates for the AC/PC/IH fiducials
AC = [0,   3,  -4] ./ 1000;
PC = [0, -25,  -2] ./ 1000;
IH = [0, -10,  60] ./ 1000;
Origin = [0, 0, 0];
% Convert: MNI (meters) => MRI (millimeters)
sMri.NCS.AC = cs_convert(sMri, 'mni', 'mri', AC) .* 1000;
sMri.NCS.PC = cs_convert(sMri, 'mni', 'mri', PC) .* 1000;
sMri.NCS.IH = cs_convert(sMri, 'mni', 'mri', IH) .* 1000;
sMri.NCS.Origin = cs_convert(sMri, 'mni', 'mri', Origin) .* 1000;

%% = MRI=>SCS TRANSFORMATION =
% Set the MRI=>SCS transformation in the MRI
Tscs = transform.vox07mm2bti * Tbst2ft;
sMri.SCS.R = Tscs(1:3,1:3);
sMri.SCS.T = Tscs(1:3,4);
% Standard positions for the SCS fiducials
NAS = [90,   0, 0] ./ 1000;
LPA = [ 0,  75, 0] ./ 1000;
RPA = [ 0, -75, 0] ./ 1000;
Origin = [0, 0, 0];
% Convert: SCS (meters) => MRI (millimeters)
sMri.SCS.NAS= cs_convert(sMri, 'scs', 'mri', NAS) .* 1000;
sMri.SCS.LPA= cs_convert(sMri, 'scs', 'mri', LPA) .* 1000;
sMri.SCS.RPA= cs_convert(sMri, 'scs', 'mri', RPA) .* 1000;
sMri.SCS.Origin = cs_convert(sMri, 'scs', 'mri', Origin) .* 1000;
% Save MRI structure (with fiducials)
bst_save(BstMriFile, sMri, 'v7');

and here is the relevant contents of the transform file I got with the HCP-MEG 
example recommended by BS:

transform.vox07mm_filename = 'T1w_acpc_dc_restore.nii.gz';
transform.vox_filename = '175237_MEG_anatomy_anatomical.nii';
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
];
transform.vox07mm2bti = [
0.0242485 0.689697 -0.143363 -99.3102
0.702637 -0.0220904 0.00540799 -88.0016
-5.54434e-05 0.143686 0.684532 -77.7522
0 0 0 1
];


So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. One dis

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-14 Thread Georgios Michalareas
@esi-frankfurt.de]
*Sent:* Friday, February 10, 2017 4:50 PM
*To:* K Jeffrey Eriksen
*Subject:* RE: [HCP-Users] MEG_anatomy_transform.txt

I think this should not be a problem.

Just use the T1 you have but make sure the fields names of the 
"transform" structure remain the same as in the description I sent you 
because I am pretty confident that Brainstorm is expecting to find 
these exact filenames,


Give it a try snd let me know how it goes

Best

Giorgos



*From:*K Jeffrey Eriksen [eriks...@ohsu.edu]
*Sent:* Saturday, February 11, 2017 1:02 AM
*To:* Michalareas, Giorgos
*Subject:* RE: [HCP-Users] MEG_anatomy_transform.txt

Georgios,

I have read through this now, and have one follow-up question.  While 
we are using the HCP pipeline, our original T1s are 1.0 mm cubic 
voxels. Could you please comment on this, or possibly modify what you 
have written to accommodate this fact?


Thanks,

-Jeff

*From:*hcp-users-boun...@humanconnectome.org 
<mailto:hcp-users-boun...@humanconnectome.org> 
[mailto:hcp-users-boun...@humanconnectome.org] *On Behalf Of *Georgios 
Michalareas

*Sent:* Friday, February 10, 2017 3:05 PM
*To:* hcp-users@humanconnectome.org <mailto:hcp-users@humanconnectome.org>
*Subject:* Re: [HCP-Users] MEG_anatomy_transform.txt

Dear Jeff,

if I have understood correctly you want to import a structural MRI 
scan for a given HCP subject into Brainstorm for creating the EEG 
source model.


I guess you follow a procedure similar to

http://neuroimage.usc.edu/brainstorm/Tutorials/HCP-MEG

and Brainstorm cannot find the MEG/anatomy/*_MEG_anatomy_transform.txt 
file.


Although I am not sure whar Brainstorm reads exactly from the 
transform file , I can tell you what the transorm file contains. It 
contains a matlab structure with some fields, which I think you could 
easily create for subject that have no MEG data.



First a quick word on coordinate systems:

spm: This is the MNI coordinate system. This is the coordinate system 
that you 0.7 mm processed structural MRI is defined.


bti: This is the coordinate system of the MEG . Of course in your case 
where there was no MEG recorded , this will be the same as the "spm" 
coordinate system of the structural MRI. If for your EEG you have 
digitised the location of the EEG sensors relative to the fiducials 
then of course you ll need to figure out the transformation matrix 
between the structural MRI and you EEG reference system. But if this 
is not the case then your "bti" coordinate system should be the same 
as the "spm" coordinate system. In this case the identity 
transformation matrices between this coordinate systems would be


spm2bti= [
  1 0 0 0
  0 1 0 0
  0 0 1 0
  0 0 0 1
];

bti2spm= spm2bti;


vox: This is the voxel coordinate system of the structural MRI . The 
MRI file contains in itself the transformation matrix from voxels to 
actual coordinates in the "spm". To get this transformation matric in 
matlab you can use the fieldtrip function "ft_read_mri"


Let's assume you have done so and you have found that the 
transformation matrix from voxel to coordinates is


vox07mm2spm= [
 0.0296775 0.00303441 -0.996087 92.0035
 -0.965804 -0.245889 -0.0309473 159.445
 0.253714 -0.970409 0.00438009 90.3328
 0 0 0 1
];


Important remark: The HCP processed structural MRI has a resolution of 
0.7mm. For the MEG processing we use a lower resolution version of the 
structural MRI . So in the description below whenever you see the 
notation "vox07" refers to the 0.7mm scan and just "vox" to the lower 
resolution one. In your case of course these should be the same as you 
only have the 0.7 mm one.



The structure matlab variable is called "transform". I have  put the 
description of the fields in form of code , so potentially you could 
run it and create the structure for the transform file.


Its fields are:
*%==*

*transform.vox07mm_filename *= 'T1w_acpc_dc_restore.nii.gz'; % This is 
the name of the HCP processed stuctural MRI with 0.7mm resolution
*transform.vox_filename* = transform.vox07mm_filename ; % This is 
supposed to be the lower resolution version used for MEG but here you 
assign it also to the 0.7mm
*transform.vox07mm2spm* = vox07mm2spm; %This is the transformation 
matrix from voxel to "spm" coordinates mentioned earlier retrieved 
from the 0.7mm structural MRI.
*transform.spm2vox07mm* = inv(transform.vox2spm); % This is the 
inverse transformation of the above from "spm" coordinates to voxels.


*transform.vox2spm *=transform.vox07mm2spm; %This is the 
transformation matrix from voxel to "spm" coordinates mentioned 
earlier . As you only have the 0.7mm structural here is the same also 
for the lower resolution case.
*transform.spm2vox* = inv(transform.vox2spm); % This is the inv

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-13 Thread K Jeffrey Eriksen
Georgos,

Understood about the naming.

Next question: I have found the Brainstorm code that reads the transform file:

%% = MRI=>MNI TRANSFORMATION =
% Convert transformations from "Brainstorm MRI" to "FieldTrip voxel"
Tbst2ft = [diag([-1, 1, 1] ./ sMri.Voxsize), [size(sMri.Cube,1); 0; 0]; 0 0 0 
1];
% Set the MNI=>SCS transformation in the MRI
Tmni = transform.vox07mm2spm * Tbst2ft;
sMri.NCS.R = Tmni(1:3,1:3);
sMri.NCS.T = Tmni(1:3,4);
% MNI coordinates for the AC/PC/IH fiducials
AC = [0,   3,  -4] ./ 1000;
PC = [0, -25,  -2] ./ 1000;
IH = [0, -10,  60] ./ 1000;
Origin = [0, 0, 0];
% Convert: MNI (meters) => MRI (millimeters)
sMri.NCS.AC = cs_convert(sMri, 'mni', 'mri', AC) .* 1000;
sMri.NCS.PC = cs_convert(sMri, 'mni', 'mri', PC) .* 1000;
sMri.NCS.IH = cs_convert(sMri, 'mni', 'mri', IH) .* 1000;
sMri.NCS.Origin = cs_convert(sMri, 'mni', 'mri', Origin) .* 1000;

%% = MRI=>SCS TRANSFORMATION =
% Set the MRI=>SCS transformation in the MRI
Tscs = transform.vox07mm2bti * Tbst2ft;
sMri.SCS.R = Tscs(1:3,1:3);
sMri.SCS.T = Tscs(1:3,4);
% Standard positions for the SCS fiducials
NAS = [90,   0, 0] ./ 1000;
LPA = [ 0,  75, 0] ./ 1000;
RPA = [ 0, -75, 0] ./ 1000;
Origin = [0, 0, 0];
% Convert: SCS (meters) => MRI (millimeters)
sMri.SCS.NAS= cs_convert(sMri, 'scs', 'mri', NAS) .* 1000;
sMri.SCS.LPA= cs_convert(sMri, 'scs', 'mri', LPA) .* 1000;
sMri.SCS.RPA= cs_convert(sMri, 'scs', 'mri', RPA) .* 1000;
sMri.SCS.Origin = cs_convert(sMri, 'scs', 'mri', Origin) .* 1000;
% Save MRI structure (with fiducials)
bst_save(BstMriFile, sMri, 'v7');

and here is the relevant contents of the transform file I got with the HCP-MEG 
example recommended by BS:

transform.vox07mm_filename = 'T1w_acpc_dc_restore.nii.gz';
transform.vox_filename = '175237_MEG_anatomy_anatomical.nii';
transform.vox07mm2spm = [
-0.7 0 0 90.7
0 0.7 0 -126.7
0 0 0.7 -72.7
0 0 0 1
];
transform.vox07mm2bti = [
0.0242485 0.689697 -0.143363 -99.3102
0.702637 -0.0220904 0.00540799 -88.0016
-5.54434e-05 0.143686 0.684532 -77.7522
0 0 0 1
];


So only two of the transforms in the transform.vox_filename = 
'_MEG_anatomy_anatomical.txt' are needed by BS. I just have to figure 
out how to create them for my non-MEG data. One disconnect I am having is that 
below (from your earlier email) you say these two are identical, but BS 
obviously does not think so as they are obviously different in the above 
snippet:



>>transform.vox07mm2spm = vox07mm2spm; %This is the transformation matrix from 
>>voxel to "spm" coordinates mentioned earlier retrieved from the 0.7mm 
>>structural MRI.



>>transform.vox07mm2bti = transform.vox07mm2spm ; % As spm and bti are 
>>identical coordinate system this is just the transformation from voxels to 
>>"spm" coordinates already created;

I do not process MRI data myself, concentrating on the EEG analysis) so do not 
know how to setup and run the HCP pipeline or the special HCP_MEG pipeline. I 
did try searching all the HCP_MEG pipeline M-files and found no occurrence of 
the transforms above, so they must be embedded in the shell scripts or compiled 
C code somewhere, presumably.

Can you comment on the above and perhaps point me in the right direction? One 
idea I have is to try to run the HCP-MEG pipeline minus the actual MEG 
portions. Another is to find out if the standard HCP pipeline produces the 
transforms I need.

Thanks,
-Jeff


From: Michalareas, Giorgos [mailto:giorgos.michalar...@esi-frankfurt.de]
Sent: Friday, February 10, 2017 4:50 PM
To: K Jeffrey Eriksen
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt

I think this should not be a problem.
Just use the T1 you have but make sure the fields names of the "transform" 
structure remain the same as in the description I sent you because I am pretty 
confident that Brainstorm is expecting to find these exact filenames,
Give it a try snd let me know how it goes
Best
Giorgos




From: K Jeffrey Eriksen [eriks...@ohsu.edu]
Sent: Saturday, February 11, 2017 1:02 AM
To: Michalareas, Giorgos
Subject: RE: [HCP-Users] MEG_anatomy_transform.txt
Georgios,

I have read through this now, and have one follow-up question.  While we are 
using the HCP pipeline, our original T1s are 1.0 mm cubic voxels. Could you 
please comment on this, or possibly modify what you have written to accommodate 
this fact?

Thanks,
-Jeff

From: 
hcp-users-boun...@humanconnectome.org<mailto:hcp-users-boun...@humanconnectome.org>
 [mailto:hcp-users-boun...@humanconnectome.org] On Behalf Of Georgios 
Michalareas
Sent: Friday, February 10, 2017 3:05 PM
To: hcp-users@humanconnectome.org<mailto:hcp-users@humanconnectome.org>
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Dear Jeff,

if I have understood correctly you want to import a structural MRI scan for a 
given HCP subject into Brainstorm for creating the 

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-10 Thread K Jeffrey Eriksen
Hi Giorgios,

I believe you have understood my problem correctly and what you have provided 
here looks like it is appropriate and complete. I will try to follow your 
example and see how it goes.

I also do not know exactly what Brainstorm needs from the transform file, and 
am trying to get them to tell me. They have at least pointed me to the 
Brainstorm M-file that imports the HCP-MEG files, and I might be able to figure 
that out on my own.

Thank you for the quick response, much appreciated.

-Jeff

From: hcp-users-boun...@humanconnectome.org 
[mailto:hcp-users-boun...@humanconnectome.org] On Behalf Of Georgios Michalareas
Sent: Friday, February 10, 2017 3:05 PM
To: hcp-users@humanconnectome.org
Subject: Re: [HCP-Users] MEG_anatomy_transform.txt


Dear Jeff,

if I have understood correctly you want to import a structural MRI scan for a 
given HCP subject into Brainstorm for creating the EEG source model.

I guess you follow a procedure similar to

http://neuroimage.usc.edu/brainstorm/Tutorials/HCP-MEG

and Brainstorm cannot find the MEG/anatomy/*_MEG_anatomy_transform.txt file.

Although I am not sure whar Brainstorm reads exactly from the transform file , 
I can tell you what the transorm file contains. It contains a matlab structure 
with some fields, which I think you could easily create for subject that have 
no MEG data.


First a quick word on coordinate systems:

spm: This is the MNI coordinate system. This is the coordinate system that you 
0.7 mm processed structural MRI is defined.

bti: This is the coordinate system of the MEG . Of course in your case where 
there was no MEG recorded , this will be the same as the "spm" coordinate 
system of the structural MRI. If for your EEG you have digitised the location 
of the EEG sensors relative to the fiducials then of course you ll need to 
figure out the transformation matrix between the structural MRI and you EEG 
reference system. But if this is not the case then your "bti" coordinate system 
should be the same as the "spm" coordinate system. In this case the identity 
transformation matrices between this coordinate systems would be

spm2bti= [
  1 0 0 0
  0 1 0 0
  0 0 1 0
  0 0 0 1
];

bti2spm= spm2bti;


vox: This is the voxel coordinate system of the structural MRI . The MRI file 
contains in itself the transformation matrix from voxels to actual coordinates 
in the "spm". To get this transformation matric in matlab you can use the 
fieldtrip function "ft_read_mri"

Let's assume you have done so and you have found that the transformation matrix 
from voxel to coordinates is

vox07mm2spm= [
 0.0296775 0.00303441 -0.996087 92.0035
 -0.965804 -0.245889 -0.0309473 159.445
 0.253714 -0.970409 0.00438009 90.3328
 0 0 0 1
];


Important remark: The HCP processed structural MRI has a resolution of 0.7mm. 
For the MEG processing we use a lower resolution version of the structural MRI 
. So in the description below whenever you see the notation "vox07" refers to 
the 0.7mm scan and just "vox" to the lower resolution one. In your case of 
course these should be the same as you only have the 0.7 mm one.


The structure matlab variable is called "transform". I have  put the 
description of the fields in form of code , so potentially you could run it and 
create the structure for the transform file.

Its fields are:
%==

transform.vox07mm_filename = 'T1w_acpc_dc_restore.nii.gz'; % This is the name 
of the HCP processed stuctural MRI with 0.7mm resolution
transform.vox_filename = transform.vox07mm_filename ; % This is supposed to be 
the lower resolution version used for MEG but here you assign it also to the 
0.7mm
transform.vox07mm2spm = vox07mm2spm; %This is the transformation matrix from 
voxel to "spm" coordinates mentioned earlier retrieved from the 0.7mm 
structural MRI.
transform.spm2vox07mm = inv(transform.vox2spm); % This is the inverse 
transformation of the above from "spm" coordinates to voxels.

transform.vox2spm =transform.vox07mm2spm; %This is the transformation matrix 
from voxel to "spm" coordinates mentioned earlier . As you only have the 0.7mm 
structural here is the same also for the lower resolution case.
transform.spm2vox = inv(transform.vox2spm); % This is the inverse 
transformation of the above from "spm" coordinates to voxels.

transform.spm2bti = spm2bti; % This is the transformation between spm and bti 
coordinate systems. In this case it is assumed they are the same so it the 
identity matrix created earlier.
transform.bti2spm =  bti2spm; %Same case here

transform.vox07mm2bti = transform.vox07mm2spm ; % As spm and bti are identical 
coordinate system this is just the transformation from voxels to "spm" 
coordinates already created;
transform.bti2vox07mm =  transform.spm2vox07mm; % The same is true for the 
inverse transformation.
tran

Re: [HCP-Users] MEG_anatomy_transform.txt

2017-02-10 Thread Georgios Michalareas

Dear Jeff,

if I have understood correctly you want to import a structural MRI scan 
for a given HCP subject into Brainstorm for creating the EEG source model.


I guess you follow a procedure similar to

http://neuroimage.usc.edu/brainstorm/Tutorials/HCP-MEG

and Brainstorm cannot find the MEG/anatomy/*_MEG_anatomy_transform.txt file.

Although I am not sure whar Brainstorm reads exactly from the transform 
file , I can tell you what the transorm file contains. It contains a 
matlab structure with some fields, which I think you could easily create 
for subject that have no MEG data.



First a quick word on coordinate systems:

spm: This is the MNI coordinate system. This is the coordinate system 
that you 0.7 mm processed structural MRI is defined.


bti: This is the coordinate system of the MEG . Of course in your case 
where there was no MEG recorded , this will be the same as the "spm" 
coordinate system of the structural MRI. If for your EEG you have 
digitised the location of the EEG sensors relative to the fiducials then 
of course you ll need to figure out the transformation matrix between 
the structural MRI and you EEG reference system. But if this is not the 
case then your "bti" coordinate system should be the same as the "spm" 
coordinate system. In this case the identity transformation matrices 
between this coordinate systems would be


spm2bti= [
  1 0 0 0
  0 1 0 0
  0 0 1 0
  0 0 0 1
];

bti2spm= spm2bti;


vox: This is the voxel coordinate system of the structural MRI . The MRI 
file contains in itself the transformation matrix from voxels to actual 
coordinates in the "spm". To get this transformation matric in matlab 
you can use the fieldtrip function "ft_read_mri"


Let's assume you have done so and you have found that the transformation 
matrix from voxel to coordinates is


vox07mm2spm= [
 0.0296775 0.00303441 -0.996087 92.0035
 -0.965804 -0.245889 -0.0309473 159.445
 0.253714 -0.970409 0.00438009 90.3328
 0 0 0 1
];


Important remark: The HCP processed structural MRI has a resolution of 
0.7mm. For the MEG processing we use a lower resolution version of the 
structural MRI . So in the description below whenever you see the 
notation "vox07" refers to the 0.7mm scan and just "vox" to the lower 
resolution one. In your case of course these should be the same as you 
only have the 0.7 mm one.



The structure matlab variable is called "transform". I have put the 
description of the fields in form of code , so potentially you could run 
it and create the structure for the transform file.


Its fields are:
*%==*

*transform.vox07mm_filename *= 'T1w_acpc_dc_restore.nii.gz'; % This is 
the name of the HCP processed stuctural MRI with 0.7mm resolution
*transform.vox_filename* = transform.vox07mm_filename ; % This is 
supposed to be the lower resolution version used for MEG but here you 
assign it also to the 0.7mm
*transform.vox07mm2spm* = vox07mm2spm; %This is the transformation 
matrix from voxel to "spm" coordinates mentioned earlier retrieved from 
the 0.7mm structural MRI.
*transform.spm2vox07mm* = inv(transform.vox2spm); % This is the inverse 
transformation of the above from "spm" coordinates to voxels.


*transform.vox2spm *=transform.vox07mm2spm; %This is the transformation 
matrix from voxel to "spm" coordinates mentioned earlier . As you only 
have the 0.7mm structural here is the same also for the lower resolution 
case.
*transform.spm2vox* = inv(transform.vox2spm); % This is the inverse 
transformation of the above from "spm" coordinates to voxels.


*transform.spm2bti* = spm2bti; % This is the transformation between spm 
and bti coordinate systems. In this case it is assumed they are the same 
so it the identity matrix created earlier.

*transform.bti2spm* =  bti2spm; %Same case here

*transform.vox07mm2bti* = transform.vox07mm2spm ; % As spm and bti are 
identical coordinate system this is just the transformation from voxels 
to "spm" coordinates already created;
*transform.bti2vox07mm *=  transform.spm2vox07mm; % The same is true for 
the inverse transformation.
*transform.vox2bti* =  transform.vox2spm; %  Same for the lower 
resolution case used for MEG, which of course yo dont have, as yo uonly 
have the 0.7 mm so this is the same as for the 0.7mm  case



*transform.bti2vox *= transform.spm2vox; % Same  for the inverse 
transform of the lower resolution case



*transform.vox2bti_registered* = transform.vox2bti; % This is an 
intermediate transformation from voxel to bti used only for MEG purposed 
but for your case should be exactly the same as the voxel to bti 
transformation which of course is the same as the voxel to spm 
transformation as these coordinate systems are the same in your case.

*%==*


Once you have created the "transform" variable you have to write it in 
an ascii file, which is not as strightforward as writing a numberical