SelectRange.m 787 B

1234567891011121314151617181920212223
  1. % Inspect a subject and extract a range of interest
  2. import tools.GetCSVs;
  3. subjectPath = uigetdir("Please choose a subject");
  4. modulesPath = fullfile(subjectPath, 'Modules');
  5. times = inputdlg({'Begin time (in seconds, first second is 1)', 'End time (in seconds, first second is 1)'}, 'Time frame inspector');
  6. start = str2num(times{1});
  7. stop = str2num(times{2});
  8. [modules csvs]= GetCSVs(modulesPath, "Mouse");
  9. for i=1:length(modules)
  10. data = readmatrix(fullfile(modulesPath, csvs{i}));
  11. out = data(start:stop, :)
  12. if i == 1
  13. filteredPath = fullfile(modulesPath, sprintf("Filtered-%d-%d", start, stop));
  14. disp(filteredPath);
  15. mkdir(filteredPath);
  16. end
  17. outPath = fullfile(filteredPath, string(modules{i}) + ".csv");
  18. writematrix(out, outPath);
  19. end