Skip to content

Commit c5cf158

Browse files
committed
bugs fix, introduce wiatbars
1 parent 7373dde commit c5cf158

File tree

3 files changed

+31
-13
lines changed

3 files changed

+31
-13
lines changed

gui.m

+16-11
Original file line numberDiff line numberDiff line change
@@ -266,18 +266,13 @@ function load_traj_buttom_Callback(hObject, eventdata, handles)
266266
else
267267
% Ask if the user wish to create animal groups
268268
choice = questdlg('Would you like to assign animals to groups?', ...
269-
'Assign Animals to Groups','Yes','No','No');
269+
'Assign Animals to Groups','Yes','No','No');
270+
% set current GUI visibility to off
271+
temp = findall(gcf);
272+
set(temp,'Visible','off');
270273
switch choice
271-
case 'Yes'
272-
% set current GUI visibility to off
273-
temp = findall(gcf);
274-
set(temp,'Visible','off');
275-
[groups_path] = animal_groups(paths, get(handles.field_id,'String'), str2num(get(handles.text_sessions,'String')));
276-
% resume main GUI visibility
277-
set(temp,'Visible','on');
278-
if isempty(groups_path)
279-
return;
280-
end
274+
case 'Yes'
275+
[groups_path] = animal_groups(paths, get(handles.field_id,'String'), str2num(get(handles.text_sessions,'String')));
281276
case 'No'
282277
groups_path = {};
283278
disp('No animal groups specified. All animals will belong to group 1');
@@ -318,8 +313,18 @@ function load_traj_buttom_Callback(hObject, eventdata, handles)
318313
% compute segments and features
319314
segmentation_configs = config_segments(user_input);
320315
if isempty(segmentation_configs.TRAJECTORIES)
316+
% resume main GUI visibility
317+
set(temp,'Visible','on');
318+
if isempty(groups_path)
319+
return;
320+
end
321321
return;
322322
end
323+
% resume main GUI visibility
324+
set(temp,'Visible','on');
325+
if isempty(groups_path)
326+
return;
327+
end
323328
% check if object is already cached and if not save it
324329
rpath = check_cached_objects(segmentation_configs,1);
325330
set(handles.seg_path,'String',rpath);

segmentation/parse_data_simplified.m

+10-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
break
1919
end
2020
end
21+
str = ['Parsing Animal IDs from folder: ',sscanf(f(k).name,'%s')];
22+
h = waitbar(0,str,'Name','Parsing animal IDs');
2123
for j = 1:length(files)
2224
[~, ~, ext] = fileparts(fullfile(new_path,'/',files(j).name));
2325
if isequal(ext,'.CSV') || isequal(ext,'.csv')
@@ -49,7 +51,11 @@
4951
[~, ~, data] = xlsread(fullfile(new_path,'/',files(j).name));
5052
while i <= size(data,1)
5153
if isequal(data{i,1},id_field)
52-
id = data{i,2};
54+
if isnumeric(data{i,2})
55+
id = data{i,2};
56+
else
57+
id = str2num(data{i,2});
58+
end
5359
break;
5460
end
5561
i = i+1;
@@ -61,9 +67,12 @@
6167
ids_temp = [ids_temp, id];
6268
catch
6369
errordlg('Animal ID not found. Check the provided ID Field','Parse ID Error');
70+
close(h);
6471
return
6572
end
73+
waitbar(j/length(files));
6674
end
75+
close(h);
6776
% store the unique animal ids per session
6877
ids{session} = unique(ids_temp);
6978
ids_temp = [];

segmentation/set_data.m

+5-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
end
1414

1515
fprintf('Importing %d trajectories...\n', length(files));
16+
str = ['Importing ',num2str(length(files)),' trajectories'];
17+
h = waitbar(0,str,'Name','Importing trajectories');
1618

1719
for i = 1:length(files)
1820
data = parse_data(fullfile(path, files(i).name),...
@@ -112,6 +114,8 @@
112114
traj_num = i;
113115
traj = traj.append(trajectory(pts, session, track, group, id, trial, day, segment, off, starti, trial_type, traj_num));
114116
end
115-
end
117+
waitbar(i/length(files));
118+
end
119+
close(h);
116120
end
117121

0 commit comments

Comments
 (0)