0001 function obj = pr_basic_ui(imgs, dispf)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 if nargin < 1
0014 imgs = '';
0015 end
0016 if isempty(imgs)
0017 imgs = spm_get(Inf, 'img', 'Image(s) to display');
0018 end
0019 if ischar(imgs)
0020 imgs = cellstr(imgs);
0021 end
0022 if nargin < 2
0023 dispf = 1;
0024 end
0025
0026 spm_input('!SetNextPos', 1);
0027
0028
0029 nimgs = size(imgs);
0030
0031
0032 nchars = 20;
0033 imgns = spm_str_manip(imgs, ['rck' num2str(nchars)]);
0034
0035
0036 obj = slover;
0037
0038
0039 cscale = [];
0040 deftype = 1;
0041 obj.cbar = [];
0042 for i = 1:nimgs
0043 obj.img(i).vol = spm_vol(imgs{i});
0044 options = {'Structural','Truecolour', ...
0045 'Blobs','Negative blobs','Contours'};
0046
0047 [XYZ Z M] = pr_get_spm_results;
0048 if ~isempty(XYZ)
0049 options = {'Structural with SPM blobs', options{:}};
0050 end
0051 itype = spm_input(sprintf('Img %d: %s - image type?', i, imgns{i}), '+1', ...
0052 'm', char(options),options, deftype);
0053 imgns(i) = {sprintf('Img %d (%s)',i,itype{1})};
0054 [mx mn] = slover('volmaxmin', obj.img(i).vol);
0055 if ~isempty(strmatch('Structural', itype))
0056 obj.img(i).type = 'truecolour';
0057 obj.img(i).cmap = gray;
0058 obj.img(i).range = [mn mx];
0059 deftype = 2;
0060 cscale = [cscale i];
0061 if strcmp(itype,'Structural with SPM blobs')
0062 obj = add_spm(obj);
0063 end
0064 else
0065 cprompt = ['Colormap: ' imgns{i}];
0066 switch itype{1}
0067 case 'Truecolour'
0068 obj.img(i).type = 'truecolour';
0069 dcmap = 'flow.lut';
0070 drange = [mn mx];
0071 cscale = [cscale i];
0072 obj.cbar = [obj.cbar i];
0073 case 'Blobs'
0074 obj.img(i).type = 'split';
0075 dcmap = 'hot';
0076 drange = [0 mx];
0077 obj.img(i).prop = 1;
0078 obj.cbar = [obj.cbar i];
0079 case 'Negative blobs'
0080 obj.img(i).type = 'split';
0081 dcmap = 'winter';
0082 drange = [0 mn];
0083 obj.img(i).prop = 1;
0084 obj.cbar = [obj.cbar i];
0085 case 'Contours'
0086 obj.img(i).type = 'contour';
0087 dcmap = 'white';
0088 drange = [mn mx];
0089 obj.img(i).prop = 1;
0090 end
0091 obj.img(i).cmap = sf_return_cmap(cprompt, dcmap);
0092 obj.img(i).range = spm_input('Img val range for colormap','+1', 'e', drange, 2);
0093 end
0094 end
0095 ncmaps=length(cscale);
0096 if ncmaps == 1
0097 obj.img(cscale).prop = 1;
0098 else
0099 remcol=1;
0100 for i = 1:ncmaps
0101 ino = cscale(i);
0102 obj.img(ino).prop = spm_input(sprintf('%s intensity',imgns{ino}),...
0103 '+1', 'e', ...
0104 remcol/(ncmaps-i+1),1);
0105 remcol = remcol - obj.img(ino).prop;
0106 end
0107 end
0108
0109 obj.transform = deblank(spm_input('Image orientation', '+1', ['Axial|' ...
0110 ' Coronal|Sagittal'], strvcat('axial','coronal','sagittal'), ...
0111 1));
0112
0113
0114 obj.figure = spm_figure('GetWin', 'Graphics');
0115
0116
0117 obj = fill_defaults(obj);
0118 slices = obj.slices;
0119 obj.slices = spm_input('Slices to display (mm)', '+1', 'e', ...
0120 sprintf('%0.0f:%0.0f:%0.0f',...
0121 slices(1),...
0122 mean(diff(slices)),...
0123 slices(end))...
0124 );
0125
0126
0127 if dispf, obj = paint(obj); end
0128
0129 return
0130
0131
0132
0133
0134 function cmap = sf_return_cmap(prompt,defmapn)
0135 cmap = [];
0136 while isempty(cmap)
0137 [cmap w]= slover('getcmap', spm_input(prompt,'+1','s', defmapn));
0138 if isempty(cmap), disp(w);end
0139 end
0140 return