combine and delete labels

Forums Forums General Questions combine and delete labels

This topic contains 5 replies, has 3 voices, and was last updated by  mike214 1 week, 5 days ago.

  • Author
    Posts
  • #968

    mike214
    Participant

    Dear BrainSuite team

    Great toolbox. Great work with the GUI!
    I’ve tried now for several days…..without any success.
    Related to my research question, I need an atlas (in MNI space for group comparisons) that is based on fear-related brain regions (amygdala, OFC…etc). Therefore, I wanted to
    1) delete labels in the BrainAtlas1 which are not fear-related
    2) combine the hemispheric labels to bilateral labels

    I’ve tried with masking, painting…whatever. Is it really so hard ? It seems to…
    Would be nice to have two new buttons in the next release: delete and combine labels. That would be nice!

    many thanks for your efforts, mike

  • #969

    Anand Joshi
    Moderator

    Thanks, Mike for your feedback. With the current release, you can use the Matlab functions from SVReg source code to load the label nifti files in Matlab, delete and combine the labels you want, and then save the file.

    Here is a pseudocode

    v=load_nii_BIG_Lab(labelfilename);
    v.img(v.img==l1||v.img==l2)=l1; %combine labels l1 and l2
    v.img(v.img==l3)=0; %delete label l3
    save_untouch_nii(out_file, v)

  • #970

    David Shattuck
    Keymaster

    One way you can do this is by using the LabelMask tool, which is in the Delineation Panel. If you press ‘Update List’ you will see all of the labels that are in the label volume. Select all of the ones you want to keep, then press Make Mask. If you then load the label file as the primary volume, you can then apply the mask to the volume (press ‘Apply’), and it will set all of the labels outside of the mask to 0. Save the primary volume as your new label volume, and then load it. It should only have the labels that you want.

  • #971

    mike214
    Participant

    many thanks for your help!
    Both ways worked well, except combining the labels

    v.img(v.img==l1||v.img==l2)=l1; %combine labels l1 and l2
    returns
    Operands to the || and && operators must be convertible to logical scalar values

    using only | instead of || does not combine the labels…

    any idea ?
    many thanks, mike

  • #972

    Anand Joshi
    Moderator

    For combining
    v.img(v.img==l1|v.img==l2)=l1;
    should work. What happens when you do that?

  • #973

    mike214
    Participant

    yes, it does! sry, was checking wrong filename.
    Great! You saved my publication 🙂
    many thanks

You must be logged in to reply to this topic.