Assuming that your label values don't have any overlap (each integer
uniquely identifies not only the area but also the hemisphere), you can do
the math part with wb_command -volume-math:

wb_command -volume-math 'L + (L == 0) * R'  ${Subject}.custom_raw.nii.gz
-var L ${Subject}.L.custom.nii -var R ${Subject}.R.custom.nii

You can then make the combined label names text file and use it to reimport
the label file:

wb_command -volume-label-export-table ${Subject}.L.custom.nii 1
${Subject}.L.custom.txt
wb_command -volume-label-export-table ${Subject}.R.custom.nii 1
${Subject}.R.custom.txt
cat ${Subject}.L.custom.txt ${Subject}.R.custom.txt > ${Subject}.custom.txt
wb_command
-volume-label-import ${Subject}.custom_raw.nii.gz
${Subject}.custom.txt ${Subject}.custom.nii.gz

I also suggest using .nii.gz, label files compress very well.  Unlike FSL,
workbench doesn't have an environment variable controlling the output
format, you must specify full filenames.

Tim


On Mon, Oct 3, 2016 at 8:29 PM, Simon Baker <[email protected]> wrote:

> Hi all,
>
> We want to use our own custom parcellation with the connectome project
> data. Ultimately the parcellation needs to be a NIFTI volume.
>
> We mapped our own custom parcellation from fsaverage (.annot file in
> FreeSurfer space) onto an HCP subject (GIFTI surface .label.gii file in
> ${Subject}/MNINonLinear space) separately for each hemisphere, and we would
> like to convert the GIFTI surface files into a NIFTI volume file. Although
> this can be done with the following commands . . .
>
> [MNINonLinear]$ wb_command -label-to-volume-mapping
> ${Subject}.L.custom.164k_fs_LR.label.gii 
> ${Subject}.L.sphere.164k_fs_LR.surf.gii
> T1w.nii.gz ${Subject}.L.custom.nii -ribbon-constrained
> ${Subject}.L.white.164k_fs_LR.surf.gii ${Subject}.L.pial.164k_fs_LR.
> surf.gii
>
> [MNINonLinear]$ wb_command -label-to-volume-mapping
> ${Subject}.R.custom.164k_fs_LR.label.gii 
> ${Subject}.R.sphere.164k_fs_LR.surf.gii
> T1w.nii.gz ${Subject}.R.custom.nii -ribbon-constrained
> ${Subject}.R.white.164k_fs_LR.surf.gii ${Subject}.R.pial.164k_fs_LR.
> surf.gii
>
> [MNINonLinear]$ fslmaths ${Subject}.L.custom.nii -add
> ${Subject}.R.custom.nii ${Subject}.custom.nii
>
> . . . we have found that some voxels on the medial wall are labelled as
> both a left hemisphere region and a right hemisphere region.
>
> Using wb_command, how can we generate a NIFTI volume file containing both
> the left hemisphere parcellation and the right hemisphere parcellation and
> ensure that each voxel is labelled as only one region?
>
> Kind regards,
>
> Simon Baker
> Brain & Mental Health Laboratory
> Monash Institute of Cognitive & Clinical Neurosciences
> Monash University
>
> _______________________________________________
> HCP-Users mailing list
> [email protected]
> http://lists.humanconnectome.org/mailman/listinfo/hcp-users
>

_______________________________________________
HCP-Users mailing list
[email protected]
http://lists.humanconnectome.org/mailman/listinfo/hcp-users

Reply via email to