combine and delete labels

Viewing 4 reply threads
  • Author
    Posts
    • #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

            Viewing 4 reply threads
            • You must be logged in to reply to this topic.