IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
uip_dataio_txt_dpt.m
Go to the documentation of this file.
1 %> @ingroup guigroup
2 %> @file
3 %> @brief Properties Window for @ref vis_image
4 %> @image html Screenshot-uip_dataio_txt_dpt.png
5 %>
6 %> <b>Mode</b> - see vis_image::mode
7 %>
8 %> <b>Index of feature</b> - see vis_image::idx_fea
9 %>
10 %> @sa vis_image
11 
12 %> @cond
13 function varargout = uip_dataio_txt_dpt(varargin)
14 % Last Modified by GUIDE v2.5 08-Jul-2013 09:00:06
15 
16 % Begin initialization code - DO NOT EDIT
17 gui_Singleton = 1;
18 gui_State = struct('gui_Name', mfilename, ...
19  'gui_Singleton', gui_Singleton, ...
20  'gui_OpeningFcn', @uip_dataio_txt_dpt_OpeningFcn, ...
21  'gui_OutputFcn', @uip_dataio_txt_dpt_OutputFcn, ...
22  'gui_LayoutFcn', [] , ...
23  'gui_Callback', []);
24 if nargin && ischar(varargin{1})
25  gui_State.gui_Callback = str2func(varargin{1});
26 end
27 
28 if nargout
29  [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
30 else
31  gui_mainfcn(gui_State, varargin{:});
32 end
33 % End initialization code - DO NOT EDIT
34 
35 
36 % --- Executes just before uip_dataio_txt_dpt is made visible.
37 %
38 % varargin{1} is expected to be a dataio object, with filename already set
39 function uip_dataio_txt_dpt_OpeningFcn(hObject, eventdata, handles, varargin)
40 % Ignores what is usually a block that is passed to the GUI handles.input.block = varargin{1};
41 if nargin > 4
42 
43 % % % % % Tries to load spectra only (not image map)
44 % % % % % oio = dataio_txt_dpt();
45 
46 
47  handles.ds = varargin{1}.load();
48 else
49  handles.ds = [];
50 end;
51 set(handles.uipanel_transpose, 'SelectionChangeFcn', ...
52  @(hObject, eventdata) uip_dataio_txt_dpt('uipanel_transpose_SelectionChangeFcn',hObject,eventdata,guidata(hObject))); % Have to set this by hand because GUIDE does not do that automatically
53 handles.output.flag_ok = 0;
54 guidata(hObject, handles);
55 update_direction(handles);
56 handles = guidata(hObject);
57 update_dimensions(handles);
58 gui_set_position(hObject);
59 
60 %#################################################################################################
61 
62 %#########
63 function preview(handles)
64 ds = handles.ds;
65 if isempty(ds)
66  irerrordlg('Dataset not specified!', 'Cannot preview');
67  return;
68 end;
69 height = handles.heights(get(handles.popupmenu_dim, 'Value'));
70 ds.height = height;
71 ds.direction = handles.direction;
72 % if handles.flag_transpose
73 % ds.height = ds.no/height;
74 % ds = ds.transpose2();
75 % else
76 % ds.height = height;
77 % end;
78 ot = fcon_mea_area();
79 %disp('Calculating area...')
80 ds2 = ot.use(ds);
81 
82 u = vis_image();
83 u.mode = 0;
84 u.idx_fea = 1;
85 u.flag_set_position = 0;
86 vis_image01 = u;
87 cla(handles.axes1, 'reset');
88 axes(handles.axes1);
89 vis_image01.use(ds2);
90 title('');
91 
92 
93 %#########
94 function params = get_params(handles)
95 if isempty(handles.heights)
96  s_height = '[]';
97 else
98  s_height = int2str(handles.heights(get(handles.popupmenu_dim, 'Value')));
99 end;
100 params = {...
101 'height', s_height, ...
102 'direction', ['''', handles.direction, ''''], ...
103 };
104 
105 
106 %#########
107 % Called whenever the checkbox is checked/unchecked
108 function update_dimensions(handles)
109 heights = [];
110 if isempty(handles.ds)
111  strs = {'(dataset not provided)'};
112 else
113  ds = handles.ds;
114  heights = [];
115  strs = {};
116  for i = 1:ds.no
117  if ds.no/i == floor(ds.no/i)
118  heights(end+1) = i; %#ok<*AGROW>
119  strs{end+1} = sprintf('%3d x %3d', ds.no/i, i);
120  end;
121  end;
122 end;
123 handles.heights = heights;
124 set(handles.popupmenu_dim, 'Value', 1);
125 set(handles.popupmenu_dim, 'String', strs);
126 guidata(handles.figure1, handles);
127 
128 %#########
129 % Updates intrnal flag_transpose
130 function update_direction(handles)
131 handles.direction = iif(get(handles.radiobutton_hor, 'Value'), 'hor', 'ver');
132 guidata(handles.figure1, handles);
133 
134 
135 
136 %#################################################################################################
137 
138 
139 % --- Outputs from this function are returned to the command clae.
140 function varargout = uip_dataio_txt_dpt_OutputFcn(hObject, eventdata, handles)
141 try
142  uiwait(handles.figure1);
143  handles = guidata(hObject);
144  varargout{1} = handles.output;
145  delete(gcf);
146 catch
147  output.flag_ok = 0;
148  output.params = {};
149  varargout{1} = output;
150 end;
151 
152 % --- Executes on button press in pushbuttonOK.
153 function pushbuttonOK_Callback(hObject, eventdata, handles)
154 try
155  handles.output.params = get_params(handles);
156  handles.output.flag_ok = 1;
157  guidata(hObject, handles);
158  uiresume();
159 catch ME
160  irerrordlg(ME.message, 'Cannot continue');
161 
162 end;
163 
164 function uipanel_transpose_SelectionChangeFcn(hObject, eventdata, handles)
165 update_direction(handles);
166 
167 % --- Executes on selection change in popupmenu_dim.
168 function popupmenu_dim_Callback(hObject, eventdata, handles)
169 
170 % --- Executes during object creation, after setting all properties.
171 function popupmenu_dim_CreateFcn(hObject, eventdata, handles)
172 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
173  set(hObject,'BackgroundColor','white');
174 end
175 
176 function edit_idx_fea_Callback(hObject, eventdata, handles)
177 
178 % --- Executes during object creation, after setting all properties.
179 function edit_idx_fea_CreateFcn(hObject, eventdata, handles)
180 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
181  set(hObject,'BackgroundColor','white');
182 end
183 
184 % --- Executes on button press in pushbutton_preview.
185 function pushbutton_preview_Callback(hObject, eventdata, handles)
186 preview(handles);
187 function uipanel_transpose_ButtonDownFcn(hObject, eventdata, handles)
188 %> @endcond
Property mode
=0. 0: feature; 1: class; 2: y
Definition: vis_image.m:10
Base Block class.
Definition: block.m:2
function block()
Property idx_fea
=1. Index of feature in case mode is 0.
Definition: vis_image.m:13
function iif(in cond, in x1, in x2)
Dataset loader/saver common class.
Definition: dataio.m:2
function gui_set_position(in hObject)
Property no
=-1. Number of observations.
Definition: block.m:63
DPT TXT loader only.
Definition: dataio_txt_dpt.m:9
Image map.
Definition: vis_image.m:4
function irerrordlg(in errorstring, in dlgname)