Thanks for posting your solution.

A few comments: while fsl's volume spaces don't respect the origin or some
other aspects of the nifti header, they are at least consistent, so you can
concatenate two fsl-format affines with convert_xfm (which does the obvious
matrix math thing), so if you have affines that correctly go from A to B
and B to C, the concatenation will in fact go from A to C (and those are
the source and target volumes that should be used when reading the
concatenated affine).  Additionally, in workbench, the identity transform
for "world" format really means what it says, regardless of any volume
header changes, so it looks like you wouldn't need to do such a
concatenation at all for -surface-apply-affine (for surfaces, you only need
to apply transforms that actually change the coordinates - that
"identity.nofile" sounds like it is only to deal with an FOV change,
because of how some tools don't handle that nicely).

Tim


On Tue, Mar 27, 2018 at 2:43 PM, Viessmann, Olivia M. <
oviessm...@mgh.harvard.edu> wrote:

> Dear Michael and Timothy,
>
> first of all thanks for all the detailed help and suggestions. Apologies
> for the late reply, but in the end I opted for rerunning the HCP scripts
> myself, because I also wanted to adapt the “OneStepResampling" to resample
> the fMRI data into native T1 space instead of MNI and to get everything set
> up just took some time.
>
> Tim’s explanations were very helpful, in the end we used freesurfer tools
> instead of workbench to transform the surfaces from the anatomical head
> position to the subject’s head position during the EPI scans.
> There were two caveats I came across. One is that the surfaces are
> reconstructed from the orig.mgz in the FreeSurfer folder. This is the
> conformed version of the input ac-pc aligned T1. The fsl fMRI2str_fsl.mat
> registration file is from this ac-pc T1 to EPI, so an extra concatenation
> is needed. I had some issues with passing on original headers with the
> correct information, so we used the lta format which we found quite handy
> for this purpose as it keeps the source and target VOX2RAS information. The
> second issue I had was that I wanted to transform the surfaces with
> FreeSurfer's mris_surf2surf, but the HCP environment script sources an old
> version of FreeSurfer that has a bug in this function, so locally a newer
> version has to be called. So maybe it is better to try out the wb_command
> -surface-apply-affine that Thomas suggested, but we decided to go with
> mris_surf2surf as it takes the lta format.
>
> Here is the part of the script where we calculate the affine
> transformations and apply them:
>
> #The surfaces are reconstructed from the orig.mgz in the FreeSurfer
> folder. The orig.mgz is the conformed version of the input T1 (ac-pc
> aligned)
> #and has a different orientation and is flipped (the third dimension is
> A>>P as if it is a coronal scan, the ac-pc is H>>F as if it is axial).
> #The fsl registration matrix, fMRI2str_fsl.mat, is between the ac-pc T1
> and the undistorted EPI reference image.
> #So we cannot easily transform the surfaces using this transformation, we
> first have to transform from orig to ac-pc and concatenate this with
> #the fMRI2str_fsl. Here we use lta_convert
>
> #Name of the output registration from EPI to ac-pc T1
> lta_EPI2ACPC=${WriteTransformsToHere}/${NameOffMRI}2str.lta
> lta_EPI2orig=${WriteTransformsToHere}/${NameOffMRI}2orig.lta
> lta_ACPC2orig=${WriteTransformsToHere}/ACPC2orig.lta
> #convert fsl to .lta
> lta_convert --subject ${Subject} --infsl ${fMRI2str_fsl} --src
> ${EPI_dc_jac} --trg ${ACPC_T1} --outlta ${lta_EPI2ACPC}
>
> #we create an identity lta file for the registration from AC-PC T1 to
> orig.mgz
> lta_convert --subject ${Subject} --inlta identity.nofile --src ${ACPC_T1}
> --trg ${orig} --outlta ${lta_ACPC2orig}
>
> #Concatenate the two (out_type flag :1 - RAS2RAS, 0 - VOX2VOX (default))
> mri_concatenate_lta -out_type 1 ${lta_EPI2ACPC} ${lta_ACPC2orig}
> ${lta_EPI2orig}
>
> #Then call mris_surf2surf to register the surface
> /usr/local/freesurfer/freesurfer/bin/mri_surf2surf \
>     --s ${Subject} \
>     --reg ${lta_EPI2orig} \
>     --sval-xyz ${Surf} \
>     --tval-xyz ${EPI_dc_jac} \
>     --hemi ${hemi} \
>     --surfreg ${Surf} \
>     --tval ${hemi}.${Surf}_2${NameOffMRI}
>
> @Thomas: With respect to the scanner's B0 orientation:
> I calculate the orientation of the surface normals offline in Matlab and
> load them as an overlay to the surfaces in freeview. To make a sanity check
> if orientations are correct with respect to the scanner's B0-axis we load a
> circle localizer (Siemens localizer, can be from any scan). This circle
> localizer gives three orthogonal planes that are aligned with the scanner
> axes. And you are correct - the B0 axis is along +z.
>
> Thanks again for all the suggestions,
> Olivia
>
>
> ____________________________________
> Olivia Viessmann, PhD
> A.A. Martinos Center for Biomedical Imaging
> Massachusetts General Hospital
> Harvard Medical School
> Building 75, Third Ave
> <https://maps.google.com/?q=75,+Third+Ave+%0D%0ACharlestown,+MA+02129&entry=gmail&source=g>
> Charlestown, MA 02129
>
> On 28 Feb 2018, at 09:23, Hodge, Michael <hod...@wustl.edu> wrote:
>
>
> Hi Olivia,
>
> You can use a script similar to this to iterate over all the experiments
> and preprocessing resources and pull down these files for all subjects:
>
> #!/bin/bash
> #
> # ITERATE OVER 3T EXPERIMENTS
> #
> for CSVROW in $(curl -s -k --cookie JSESSIONID=$JSESSIONID https:/
> /db.humanconnectome.org/data/projects/HCP_1200/experiments?
> xsiType=xnat:mrSessionData\&columns=ID,label,URI\&format=csv | grep
> "_3T"); do
>               LABEL=$(echo $CSVROW | cut -d, -f3)
>               SUBJ=$(echo $LABEL | sed -e "s/_.*$//")
>               URI=$(echo $CSVROW | cut -d, -f4)
>               #
>               # ITERATE OVER PIPELINE RESOURCES FOR EACH EXPERIMENT
>               #
>               for RESOURCEROW in $(curl -s -k --cookie
> JSESSIONID=$JSESSIONID https://db.humanconnectome.org${URI}/
> resources?xsiType=xnat:resourceCatalog\&format=csv
> <https://db.humanconnectome.org$%7Buri%7D/resources?xsiType=xnat:resourceCatalog%5C&format=csv>);
> do
>                            RESOURCE=$(echo ${RESOURCEROW} | cut -d, -f2)
>                            #
>                            # DOWNLOAD FILES FROM FMRI PREPROC RESOURCES
>                            #
>                            if [[ $RESOURCE =~ ^.*fMRI.*_preproc ]]; then
>                                          SERIES=$(echo "$RESOURCE" | sed
> -e "s/_preproc//")
>                                          echo $SUBJ $LABEL $URI $RESOURCE
> $SERIES
>                            DIRECTORY="$SUBJ/MNINonLinear/
> Results/${SERIES}/DistortionCorrectionAndEPIToT1wReg_
> FLIRTBBRAndFreeSurferBBRbased"
>                                          mkdir -p $DIRECTORY/FieldMap
>                                          curl -s -k --cookie
> JSESSIONID=$JSESSIONID https://db.humanconnectome.org${URI}/
> resources/${RESOURCE}/files/${SERIES}/DistortionCorrectionAndEPIToT1wReg_
> FLIRTBBRAndFreeSurferBBRbased/fMRI2str.mat
> <https://db.humanconnectome.org$%7Buri%7D/resources/$%7BRESOURCE%7D/files/$%7BSERIES%7D/DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbased/fMRI2str.mat>
>  -o $DIRECTORY/fMRI2str.mat
>                                          curl -s -k --cookie
> JSESSIONID=$JSESSIONID https://db.humanconnectome.org${URI}/
> resources/${RESOURCE}/files/${SERIES}/DistortionCorrectionAndEPIToT1wReg_
> FLIRTBBRAndFreeSurferBBRbased/FieldMap/SBRef_dc_jac.nii.gz
> <https://db.humanconnectome.org$%7Buri%7D/resources/$%7BRESOURCE%7D/files/$%7BSERIES%7D/DistortionCorrectionAndEPIToT1wReg_FLIRTBBRAndFreeSurferBBRbased/FieldMap/SBRef_dc_jac.nii.gz>
>  -o $DIRECTORY/FieldMap/SBRef_dc_jac.nii.gz
>                            fi
>               done
> done
>
> You can set the JSESSIONID with this call:
>
> read -s -p "ENTER PASSWORD: " PW;JSESSIONID=`curl -s -k -u
> YOUR_USERNAME_HERE:$PW https://db.humanconnectome.org/REST/
> JSESSIONID`;export JSESSIONID;echo $JSESSIONID
>
> I hope this helps.  Note, I didn’t include the file Tim mentioned that you
> would already in your download folders.
>
> Regards,
>
> Mike
>
> *From:* hcp-users-boun...@humanconnectome.org [mailto:hcp-users-bounces@
> humanconnectome.org <hcp-users-boun...@humanconnectome.org>] *On Behalf
> Of *Viessmann, Olivia M.
> *Sent:* Tuesday, February 27, 2018 9:48 AM
> *To:* NEUROSCIENCE tim <tsc...@mst.edu>
> *Cc:* hcp-users@humanconnectome.org
> *Subject:* Re: [HCP-Users] path to bbregister .dat file for REST call
>
> Dear Tim,
>
> thanks a lot for the detailed explanation, this is all tremendously
> helpful and is indeed what I am looking for.
> I hope someone on this list knows where the transforms are stored. As soon
> as I know from where to download it I will give it a try and let you know
> if it worked.
>
> Thanks
> Olivia
>
>
>
>
> On 26 Feb 2018, at 18:22, Timothy Coalson <tsc...@mst.edu> wrote:
>
> 0307_3T/RESOURCES/rfMRI_REST1_LR_preproc/rfMR
>
>
>
> The information in this e-mail is intended only for the person to whom it
> is
> addressed. If you believe this e-mail was sent to you in error and the
> e-mail
> contains patient information, please contact the Partners Compliance
> HelpLine at
> http://www.partners.org/complianceline . If the e-mail was sent to you in
> error
> but does not contain patient information, please contact the sender and
> properly
> dispose of the e-mail.
>
> _______________________________________________
> HCP-Users mailing list
> HCP-Users@humanconnectome.org
> http://lists.humanconnectome.org/mailman/listinfo/hcp-users
>
>
> ------------------------------
> The materials in this message are private and may contain Protected
> Healthcare Information or other information of a sensitive nature. If you
> are not the intended recipient, be advised that any unauthorized use,
> disclosure, copying or the taking of any action in reliance on the contents
> of this information is strictly prohibited. If you have received this email
> in error, please immediately notify the sender via telephone or return mail.
>
>
>

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

Reply via email to