User Tools

Site Tools


creating_and_combining_masks_from_vtcs

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
creating_and_combining_masks_from_vtcs [2010/06/23 04:10] – two typos... jochencreating_and_combining_masks_from_vtcs [2010/06/25 18:48] (current) – changed comparison operator to greater or equal jochen
Line 26: Line 26:
   * clear mask object   * clear mask object
  
-===== Code =====+==== Code ====
 <code matlab create_msk_from_vtcs.m>% settings <code matlab create_msk_from_vtcs.m>% settings
 % - intensity threshold: values < 10 are treated as relative threshold! % - intensity threshold: values < 10 are treated as relative threshold!
Line 121: Line 121:
 mdm.ClearObject;</code> mdm.ClearObject;</code>
  
 +===== Alternative  algorithm =====
 +In case the MSK files/objects have already been created (e.g. as gray matter mask per subject), this is a way to average them. **This will only work if the masks are in the same space, e.g. large TAL box!**
 +
 +  * making settings (i.e. percentage threshold for combined mask)
 +  * locating all mask files to be averaged
 +  * loading all masks and adding the data
 +  * thresholding the data
 +  * saving new mask
 +
 +==== Code ====
 +<code matlab combine_existing_msks.m>% settings (80% of masks must have a set voxel)
 +gthresh = 0.8;
 +
 +% locate masks
 +%  - this could be enhanced by changing the pattern, e.g. using
 +%    'SK*_TAL*.msk' to locate only masks of subjects beginning with SK in TAL space
 +%  - additionally, the startfolder and depth could be altered
 +mskfiles = findfiles(pwd, '*.msk');
 +% alternative: mskfiles = findfiles([pwd '/SK*/VTC*/RUN*'], 'SK*TAL*.msk', 'depth=1');
 +
 +% loop over masks
 +msk = [];
 +for mc = 1:numel(mskfiles)
 +
 +    % clear old mask
 +    if ~isempty(msk)
 +        msk.ClearObject;
 +    end
 +
 +    % load mask
 +    msk = xff(mskfiles{mc});
 +    
 +    % for first mask
 +    if mc == 1
 +    
 +        % copy data
 +        mask = uint16(msk.Mask);
 +        
 +    % otherwise
 +    else
 +    
 +        % add data
 +        mask = mask + uint16(msk.Mask);
 +    end
 +end
 +
 +% threshold mask
 +mask = uint8(mask >= uint16(ceil(gthresh * numel(mskfiles))));
 +
 +% store
 +msk.Mask = mask;
 +
 +% save
 +msk.SaveAs;
 +
 +% clear object
 +msk.ClearObject;</code>
creating_and_combining_masks_from_vtcs.txt · Last modified: 2010/06/25 18:48 by jochen