Dear Chao-Gan,
Your email didn't reach the mailing list as the attachment is too large
but I did receive it.
One thing that seems to work is the following:
gl = gifti('sub-Sub003_task-rest_space-fsaverage5_hemi-L.func.gii');
Data = gl.cdata;
gl.cdata(:,:) = Data;
or if you want to copy the metadata with the second approach, do:
New.private.metadata = gl.private.metadata;
This is all a bit clunky - I'll have a look at what can be done to
simplify the syntax.
Best regards,
Guillaume.
On 21/11/2018 11:22, YAN Chao-Gan wrote:
> Dear Guillaume,
>
> Sorry for some reason I didn't receive that message in my email.
>
> Please see attached for a sample func.gii data.
>
> The first method doesn't work:
> gl = gifti('sub-Sub003_task-rest_space-fsaverage5_hemi-L.func.gii');
> Data = gl.cdata();
> gl.cdata=Data;
> Error using gifti/subsasgn (line 130)
> Syntax not implemented.
>
> The second method works, though the private metadata will be lost. When
> pass the private metadata manually, there will be a problem.
> gl = gifti('sub-Sub003_task-rest_space-fsaverage5_hemi-L.func.gii');
> Data=gl.cdata();
> New=gifti(Data);
> New.private=gl.private;
> Error using subsasgn
> Subscript argument to SUBSREF and SUBSASGN must not be
> empty.
>
> Error in gifti/subsasgn (line 56)
> this =
> builtin('subsasgn',this,subs(2:end),A);
>
> Thank you very much for your help!
>
> Best,
>
> Chao-Gan
>
>
> On Wed, Nov 21, 2018 at 6:43 PM Flandin, Guillaume <[log in to unmask]
> <mailto:[log in to unmask]>> wrote:
>
> Dear Chao-Gan,
>
> My answer also got lost in the thread!
> https://www.jiscmail.ac.uk/cgi-bin/webadmin?A2=spm;d6e87eda.1811
>
> Best regards,
> Guillaume.
>
>
> On 20/11/2018 22:41, YAN Chao-Gan wrote:
> > Dear Guillaume,
> >
> > Thank you very much for your prior reply, I had this question in
> another
> > thread but probably being buried.
> >
> > I have a question regarding to how to put time series data back to
> GIfTI
> > cdata.
> >
> > 1. Just directly put back, there would be a problem.
> > gl = gifti('sub-Sub001_task-rest_space-fsaverage5_hemi-L.func.gii');
> > Data=gl.cdata;
> > Data=someprocessing(Data);
> > gl.cdata=Data;
> > Error using gifti/subsasgn (line 130)
> > Syntax not implemented.
> >
> > 2. Use a for loop
> > gl = gifti('sub-Sub001_task-rest_space-fsaverage5_hemi-L.func.gii');
> > Data=gl.cdata;
> > Data=someprocessing(Data);
> > for i=1:size(Data,2)
> > gl.cdata(:,i)=Data(:,i);
> > end
> > Index in position 2 exceeds array bounds (must not exceed 1).
> >
> > Error in gifti/subsasgn (line 115)
> > this.data{idx(k)}.data =
> >
> > single(builtin('subsasgn',this.data{idx(k)}.data,s,A(:,k)));
> > This error occurred when i=58.
> >
> > Do you have any hints?
> >
> > Thanks,
> >
> > Chao-Gan
> >
> > On Fri, Nov 16, 2018 at 6:21 PM Flandin, Guillaume
> <[log in to unmask] <mailto:[log in to unmask]>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>>> wrote:
> >
> > Dear Chao-Gan,
> >
> > Use spm_mesh_render instead:
> > spm_mesh_render('Left1.gii')
> > otherwise, with gifti/plot, you need to do this:
> > plot(gifti('lh.white.gii'),gifti('Left1.gii'));
> >
> > I will update gifti/plot to match spm_mesh_render's behaviour
> but have a
> > look at the contextual menu with spm_mesh_render as it gives
> you a lot
> > more functionalities.
> >
> > Concerning a MATLAB-based viewer for GIfTI files, there is
> MRIcroS from
> > the prolific Chris Rorden:
> > https://www.nitrc.org/projects/mricros/
> > otherwise if there is a viewer you like but does not support
> GIfTI, we
> > should be able to find a way to export the data in a suitable
> format.
> >
> > Best regards,
> > Guillaume.
> >
> >
> > On 16/11/2018 03:52, YAN Chao-Gan wrote:
> > > Hi Rouhi and Guillaume,
> > >
> > > Thank you very much for your response!
> > >
> > > When I saved the gifti file as demonstrated by Guillaume, I can
> > not plot
> > > it. Please see below for my codes and the error message,
> could you
> > > please give me some hints?
> > > gl =
> gifti('sub-Sub001_task-rest_space-fsaverage5_hemi-L.func.gii');
> > > ggl = gifti(gl.cdata(:,1));
> > > ggl.private.metadata =
> > struct('name','SurfaceID','value','lh.white.gii');
> > > save(ggl,'Left1.gii','ExternalFileBinary');
> > > Left1=gifti('Left1.gii');
> > > plot(Left1)
> > > Error using gifti/subsref (line 24)
> > > Reference to non-existent field 'vertices'.
> > >
> > > Error in gifti/plot (line 48)
> > > 'vertices',
> > subsref(this,struct('type','.','subs','vertices')),...
> > >
> > > BTW, do you know if there is any nice matlab-based Viewer
> for gifti
> > > files? (I know I can view them in freeview, but trying to find a
> > > matlab-based one).
> > >
> > > Thanks,
> > >
> > > Chao-Gan
> > >
> > >
> > >
> > >
> > >
> > > On Sat, Nov 10, 2018 at 7:53 AM Rouhollah Abdollahi
> > <[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>
> > > <mailto:[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>>> wrote:
> > >
> > > Dear Chao-Gan,
> > >
> > > Freesurfer does not make the mid thickness surfaces. However
> > you can
> > > do it yourself by loading the pial and white surfaces in
> > Matlab and
> > > average them to make the mid thickness surface. Also I
> have to
> > > mention for the point of visualization the fsavrage
> surface is
> > > pretty good and you don’t need the mid surface one.
> > >
> > > Hope it helps
> > >
> > > Best
> > > Rouhi
> > >
> > > On Sat 10. Nov 2018 at 00:17, YAN Chao-Gan
> <[log in to unmask] <mailto:[log in to unmask]>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>>
> > > <mailto:[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>>> wrote:
> > >
> > > Hi Guillaume,
> > >
> > > Thank you very much for your response!
> > >
> > > Yes, this comes from fmriprep. Indeed there is a
> > > sub-001_hemi-L_midthickness.surf.gii for each subject,
> > however,
> > > there is no midthickness file under the fsaverage5 in
> > freesurfer.
> > >
> > > I am also ccing Chris to see if he has any
> suggestions. Hi
> > > Chris, any insights?
> > >
> > > Thanks,
> > >
> > > Chao-Gan
> > >
> > > On Fri, Nov 9, 2018 at 6:41 PM Flandin, Guillaume
> > > <[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>>> wrote:
> > >
> > > Dear Chao-Gan,
> > >
> > > I assume that these files are obtained from
> fmriprep? I
> > > don't know if
> > > things have changed in the meantime but
> rereading an email
> > > exchange I
> > > had with Chris and Oscar on this topic a year
> ago, the
> > surface
> > > (geometry) meshes for fsnative (native subject
> specific
> > > surface) are in
> > > ../anat/sub-*_T1w_midthickness.*.surf.gii while
> the other
> > > surfaces (like
> > > fsaverage5) are standard FreeSurfer surfaces and are
> > > therefore to be
> > > found in your FreeSurfer installation (possibly in a
> > > different file format).
> > >
> > > Best regards,
> > > Guillaume.
> > >
> > >
> > > On 08/11/2018 00:06, YAN Chao-Gan wrote:
> > > > Dear Guillaume,
> > > >
> > > > Thank you very much for your code example. I
> just wonder
> > > where can I
> > > > find 'mesh.surf.gii' in your example?
> > > >
> > > > For a functional image like
> > > >
> "sub-001_task-rest_space-fsaverage5_hemi-R.func.gii", I
> > > think I should
> > > > find some thing like
> > > "fsaverage5_hemi-R_midthickness.surf.gii". Do you
> > > > happen to know where would
> > > "fsaverage5_hemi-R_midthickness.surf.gii" exist?
> > > >
> > > > Thank you very much!
> > > >
> > > > Best,
> > > >
> > > > Chao-Gan
> > > >
> > > >
> > > > On Fri, Oct 13, 2017 at 11:04 PM Guillaume Flandin
> > > <[log in to unmask]
> <mailto:[log in to unmask]> <mailto:[log in to unmask]
> <mailto:[log in to unmask]>>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>>>
> > > > <mailto:[log in to unmask]
> <mailto:[log in to unmask]>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>>
> <mailto:[log in to unmask] <mailto:[log in to unmask]>
> > <mailto:[log in to unmask] <mailto:[log in to unmask]>>>>>
> > > wrote:
> > > >
> > > > Hi Patrick,
> > > >
> > > > Then, given you're not using them for proper
> > > inference, it probably
> > > > doesn't matter too much - it's just that the
> > > separation in two
> > > > hemispheres is an artefact of the
> preprocessing
> > > pipeline (eg you would
> > > > rarely do that with volumetric data).
> > > >
> > > > To combine the surface meshes, you can do
> something
> > > like this:
> > > >
> > > > M = gifti({'L.surf.gii','R.surf.gii'});
> > > > M = spm_mesh_join(M);
> > > > save(gifti(M),'mesh.surf.gii')
> > > >
> > > > and for the functional data it would be
> > something like:
> > > >
> > > > gl = gifti('L.func.gii');
> > > > gr = gifti('R.func.gii');
> > > > for i=1:size(gr.cdata,2)
> > > > gg = gifti([gl.cdata(:,i);gr.cdata(:,i)]);
> > > > gg.private.metadata =
> > > >
> struct('name','SurfaceID','value','mesh.surf.gii');
> > > >
> > > >
> > >
> >
> save(gg,spm_file('mesh.func.gii','suffix',sprintf('_%05d',i)),'ExternalFileBinary');
> > > > end
> > > >
> > > > As with the previous snippet, I haven't
> tried it
> > so it
> > > might require
> > > > adjustments...
> > > >
> > > > Best regards,
> > > > Guillaume.
> > > >
> > > >
> > > > On 13/10/17 15:39, Patrick Sadil wrote:
> > > > > Hello Guillaume,
> > > > > I see. We had only been planning on
> using
> > these
> > > data as a
> > > > really rough localizer, grabbing voxels
> that were
> > > active as
> > > > determined by an uncorrected p-value
> threshold. But,
> > > it sounds like
> > > > even that would be improved by analyzing
> the entire
> > > hemisphere
> > > > together. Sorry, to keep asking questions
> about
> > this,
> > > but do you
> > > > know of a reliable way to combine these
> hemispheres?
> > > > >
> > > > > Best,
> > > > > Patrick
> > > > >
> > > >
> > > > --
> > > > Guillaume Flandin, PhD
> > > > Wellcome Trust Centre for Neuroimaging
> > > > University College London
> > > > 12 Queen Square
> > >
> >
> <https://maps.google.com/?q=12+Queen+Square+%0D%0A+%C2%A0+%C2%A0+%C2%A0London+WC1N+3BG&entry=gmail&source=g>
> > >
> >
> <https://maps.google.com/?q=12+Queen+Square+%0D%0A+%C2%A0+%C2%A0+%C2%A0London+WC1N+3BG&entry=gmail&source=g>>
> > > London WC1N 3BG
> > >
> >
> <https://maps.google.com/?q=12+Queen+Square+%0D%0A+%C2%A0+%C2%A0+%C2%A0London+WC1N+3BG&entry=gmail&source=g>
> > > >
> > > >
> > > >
> > > > --
> > > > Chao-Gan YAN, Ph.D.
> > > > Professor, Principal Investigator
> > > > Deputy Director, Magnetic Resonance Imaging
> Research
> > Center
> > > > Institute of Psychology, Chinese Academy of
> Sciences
> > > > 16 Lincui Road, Chaoyang District, Beijing
> 100101, China
> > >
> >
> <https://maps.google.com/?q=16+Lincui+Road,+Chaoyang+District,+Beijing+100101,+China&entry=gmail&source=g>
> > > > -
> > > > Initiator
> > > > <http://rfmri.org/DPARSF>DPABI
> > > > <http://rfmri.org/DPABI><http://rfmri.org/DPARSF>,
> > > > <http://dpabi.org>DPARSF
> <http://rfmri.org/DPARSF>, PRN
> > > > <http://rfmri.org/PRN> and The R-fMRI Network
> > > <http://rfmri.org>
> > > > (RFMRI.ORG <http://RFMRI.ORG>
> <http://RFMRI.ORG> <http://RFMRI.ORG>
> > <http://rfmri.org/>)
> > > > http://rfmri.org/yan
> > > >
> http://scholar.google.com/citations?user=lJQ9B58AAAAJ
> > >
> > > --
> > > Guillaume Flandin, PhD
> > > Wellcome Centre for Human Neuroimaging
> > > UCL Queen Square Institute of Neurology
> > > London WC1N 3BG
> > >
> > >
> > >
> > > --
> > > Chao-Gan YAN, Ph.D.
> > > Professor, Principal Investigator
> > > Deputy Director, Magnetic Resonance Imaging Research
> Center
> > > Institute of Psychology, Chinese Academy of Sciences
> > > 16 Lincui Road, Chaoyang District, Beijing 100101, China
> > >
> >
> <https://maps.google.com/?q=16+Lincui+Road,+Chaoyang+District,+Beijing+100101,+China&entry=gmail&source=g>
> > > -
> > > Initiator
> > > <http://rfmri.org/DPARSF>DPABI
> > > <http://rfmri.org/DPABI><http://rfmri.org/DPARSF>,
> > > <http://dpabi.org>DPARSF <http://rfmri.org/DPARSF>, PRN
> > > <http://rfmri.org/PRN> and The R-fMRI Network
> > <http://rfmri.org>
> > > (RFMRI.ORG <http://RFMRI.ORG> <http://RFMRI.ORG>
> <http://rfmri.org/>)
> > > http://rfmri.org/yan
> > > http://scholar.google.com/citations?user=lJQ9B58AAAAJ
> > >
> > > --
> > > Sent from Gmail Mobile
> > >
> > >
> > >
> > > --
> > > Chao-Gan YAN, Ph.D.
> > > Professor, Principal Investigator
> > > Deputy Director, Magnetic Resonance Imaging Research Center
> > > Institute of Psychology, Chinese Academy of Sciences
> > > 16 Lincui Road, Chaoyang District, Beijing 100101, China
> > > -
> > > Initiator
> > > <http://rfmri.org/DPARSF>DPABI
> > > <http://rfmri.org/DPABI><http://rfmri.org/DPARSF>,
> > > <http://dpabi.org>DPARSF <http://rfmri.org/DPARSF>, PRN
> > > <http://rfmri.org/PRN> and The R-fMRI Network <http://rfmri.org>
> > > (RFMRI.ORG <http://RFMRI.ORG> <http://RFMRI.ORG>
> <http://rfmri.org/>)
> > > http://rfmri.org/yan
> > > http://scholar.google.com/citations?user=lJQ9B58AAAAJ
> >
> > --
> > Guillaume Flandin, PhD
> > Wellcome Centre for Human Neuroimaging
> > UCL Queen Square Institute of Neurology
> > London WC1N 3BG
> >
> >
> >
> > --
> > Chao-Gan YAN, Ph.D.
> > Professor, Principal Investigator
> > Deputy Director, Magnetic Resonance Imaging Research Center
> > Institute of Psychology, Chinese Academy of Sciences
> > 16 Lincui Road, Chaoyang District, Beijing 100101, China
> > -
> > Initiator
> > <http://rfmri.org/DPARSF>DPABI
> > <http://rfmri.org/DPABI><http://rfmri.org/DPARSF>,
> > <http://dpabi.org>DPARSF <http://rfmri.org/DPARSF>, PRN
> > <http://rfmri.org/PRN> and The R-fMRI Network <http://rfmri.org>
> > (RFMRI.ORG <http://RFMRI.ORG> <http://rfmri.org/>)
> > http://rfmri.org/yan
> > http://scholar.google.com/citations?user=lJQ9B58AAAAJ
>
> --
> Guillaume Flandin, PhD
> Wellcome Centre for Human Neuroimaging
> UCL Queen Square Institute of Neurology
> London WC1N 3BG
>
>
>
> --
> Chao-Gan YAN, Ph.D.
> Professor, Principal Investigator
> Deputy Director, Magnetic Resonance Imaging Research Center
> Institute of Psychology, Chinese Academy of Sciences
> 16 Lincui Road, Chaoyang District, Beijing 100101, China
> -
> Initiator
> <http://rfmri.org/DPARSF>DPABI
> <http://rfmri.org/DPABI><http://rfmri.org/DPARSF>,
> <http://dpabi.org>DPARSF <http://rfmri.org/DPARSF>, PRN
> <http://rfmri.org/PRN> and The R-fMRI Network <http://rfmri.org>
> (RFMRI.ORG <http://rfmri.org/>)
> http://rfmri.org/yan
> http://scholar.google.com/citations?user=lJQ9B58AAAAJ
--
Guillaume Flandin, PhD
Wellcome Centre for Human Neuroimaging
UCL Queen Square Institute of Neurology
London WC1N 3BG