Home > fmri > utils > ica > ica_display.m

ica_display

PURPOSE ^

ica_display

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

ica_display

 batch for slice_overlay.m

 Tries to construct a file containing a bunch of ICA component images

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %ica_display
0002 %
0003 % batch for slice_overlay.m
0004 %
0005 % Tries to construct a file containing a bunch of ICA component images
0006 %
0007 
0008 % 8/00 Petr Janata
0009 
0010 plot_types = {'ica_stack'};
0011 
0012 comp2include = 155;
0013 
0014 plot_idx = 1;
0015 things_to_plot = plot_types(plot_idx)
0016 nthings = length(things_to_plot);
0017 
0018 ADD_MASK_CONTOUR = 0;
0019 
0020 PRINT_TO_FILE = 1;
0021 printfile = 'components.ps';
0022 unix(['rm ' printfile]);
0023 
0024 clear global SO
0025 global SO
0026 
0027 rootpath = '/data1/matlab/utils/ica/testimages/';
0028 struct_img = '/data1/prime_long/25jan01JP/hires/n25jan01JP_004.img';
0029 
0030 
0031 threshold_z = 0.5;            % Threshold z-score in map for
0032                                         % including the voxel
0033                 
0034 transform_types = {'sagittal','coronal','axial'};
0035 transform_idx = 1;        % 1=sagittal, 2=coronal, 3=axial
0036 
0037 slice_ranges = [-65 65; -60 -75; -50 70]; slice_skip = 5;
0038 %slice_ranges = [-65 65; -60 -75; -50 70]; slice_skip = 5;
0039 
0040 %
0041 % Load colormaps that we might want to use
0042 %
0043 %
0044 load hot2
0045 load hot3
0046 
0047 newhot1 = brighten(hot,0.5);
0048 newhot2 = brighten(hot2,0.5);
0049 newhot3 = brighten(hot3,0.5);
0050 
0051 my_colormap = colorcube;
0052 my_colormap = hsv;
0053 
0054 for ithing = 1:nthings
0055   disp(sprintf('Working on plots for %s', things_to_plot{ithing}))
0056   switch things_to_plot{ithing}
0057     case 'ica_stack'
0058       nimg = 0;
0059       ncomp = length(comp2include);
0060 
0061       SO.transform = transform_types{transform_idx};
0062       SO.slices = ...
0063       slice_ranges(transform_idx,1):sign(diff(slice_ranges(transform_idx,:)))*slice_skip:slice_ranges(transform_idx,2);
0064       
0065       SO.labels.format = '%+02.0f';
0066       SO.cbar = [];
0067       SO.contours = [];
0068 
0069       SO.figure = spm_figure('GetWin', 'Graphics'); % use SPM figure window
0070       set(SO.figure,'DefaultLineLineWidth',1.0)
0071 
0072       % Get info on all the files in the directory
0073       P = spm_get('Files',rootpath,'*comp*.img');
0074   
0075       nvol = size(P,1);
0076       disp(sprintf('Found %d files in directory %s', nvol, rootpath))
0077 
0078       % Get the dimension info for the first file
0079       disp(sprintf('Getting info for desired %d files', ncomp))
0080       V = spm_vol(P(comp2include,:));
0081 
0082       % Load the structural
0083       nimg = nimg+1;
0084       SO.img(nimg).vol = spm_vol(struct_img);
0085       SO.img(nimg).type = 'truecolor';
0086       SO.img(nimg).prop = 1;
0087       SO.img(nimg).cmap = gray;
0088       
0089       for ic = 1:ncomp
0090     SO.figure = spm_figure('GetWin', 'Graphics'); % use SPM figure window
0091     nimg = 1;
0092     
0093     % Load the file to determine the threshold
0094 V(ic).fname
0095 fid = fopen(V(ic).fname,'rb','l');
0096     indata = fread(fid,inf,'int16')';
0097     fclose(fid);
0098 
0099     threshold = threshold_z*std(indata(:)) + mean(indata(:))
0100 %    color_range = [threshold threshold+threshold*.5];
0101 color_range = [1.5 1.6];     
0102     nimg = nimg+1;
0103 
0104     SO.img(nimg).vol = V(ic);
0105     SO.img(nimg).type = 'split';
0106     SO.img(nimg).range = color_range;
0107     SO.img(nimg).outofrange = {0, ceil(max(color_range))*2};
0108     SO.img(nimg).prop = 1;
0109     SO.img(nimg).cmap = newhot1;
0110     SO.cbar(end+1) = nimg;
0111       
0112     %    slice_overlay_contour  % display the slices
0113     slice_overlay
0114 
0115     if PRINT_TO_FILE
0116       set(gcf,'PaperPositionMode', 'auto')
0117       print('-dpsc','-painters','-noui','-append', printfile)
0118     end
0119       end % for ic=1:ncomp
0120   end % switch
0121 end
0122

Generated on Sun 25-Aug-2019 04:00:39 by m2html © 2003