source: plugins/save_overlay_as_roi.m

Last change on this file was 171, checked in by tjniskan, 8 years ago
  • Added Overlay information for plugins.
  • Added a plugin for saving Overlay as an ROI.

M aedes.m
A plugins/save_overlay_as_roi.m
M aedes_revision.m

File size: 1.5 KB
Line 
1function save_overlay_as_roi(DATA,ROI,AddInfo)
2
3if ~isfield(AddInfo,'ImageOverlay')
4        errordlg('Image Overlay not defined.','Error','modal')
5        return
6end
7
8% Get Threshold and clim
9clim = round(((AddInfo.ImageOverlayClim-AddInfo.ImOverlayMin)*256)./...
10        (AddInfo.ImOverlayMax-AddInfo.ImOverlayMin));
11if clim(1)==clim(2)
12        if clim(1)==0
13                clim(2)=1;
14        elseif clim(1)==256
15                clim(1)=255;
16        end
17end
18thold = round(((AddInfo.ImageOverlayThold-AddInfo.ImOverlayMin)*256)/...
19        (AddInfo.ImOverlayMax-AddInfo.ImOverlayMin));
20
21% Convert indexed image to RGB image
22overlay=AddInfo.ImageOverlay(:,:,:,AddInfo.CurrentVol);
23overlay=double(overlay);
24
25% Get thresholded alpha indices
26if AddInfo.ImageOverlayTholdDirPos==1
27        overlay_th = overlay<thold;
28else
29        overlay_th = overlay>thold;
30end
31
32% Get clim alpha indices
33overlay_clim = ( overlay>=clim(1) & overlay<=clim(2) );
34
35roi_mask = false(size(overlay));
36roi_mask(overlay_clim) = true;
37roi_mask(overlay_th) = false;
38
39ROI = [];
40ROI.voxels{1} = roi_mask;
41ROI.fpath{1} = '';
42ROI.fname{1} = '';
43ROI.label = 'overlay';
44ROI.color = [255 0 0];
45DateTime = datestr(now);
46RotateFlip = {};
47
48% Get default directory
49if ispref('Aedes','GetOverlayFileDir')
50        default_dir = [getpref('Aedes','GetOverlayFileDir'),'untitled.roi'];
51else
52        default_dir = [pwd,filesep,'untitled.roi'];
53end
54
55% Save ROI
56[filename,filepath] = uiputfile({'*.roi','Aedes ROI-files (*.roi)'},...
57        'Save ROI as',default_dir);
58if isequal(filename,0)
59        % Canceled
60        return
61end
62
63[fp,fn,fe]=fileparts(filename);
64
65ROI.label = fn;
66
67save([filepath,filename],'ROI','DateTime','RotateFlip');
Note: See TracBrowser for help on using the repository browser.

Powered by Trac 1.0.9.Copyright © Juha-Pekka Niskanen 2008