-
Notifications
You must be signed in to change notification settings - Fork 0
/
matfile_generator.m
59 lines (47 loc) · 1.89 KB
/
matfile_generator.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% .mat file generator
% Created by: Jenna Grieshop
% Date created: 7/25/2023
%
% Purpose: To create .mat files that correspond with bin converted .avis
%
% Inputs: LUT file (.csv or .xlsx that is formatted for the automontager
% and also included the FOVs in column E (formatted as just one number
% e.g. 3)
%
% Outputs: .mat files containing the struct and field containing the fov
% number that is used by ARFS for each confocal video in the data folder
%
% Developed with MATLAB 2023b, need at least 2022b to run
clear all
close all
clc
%% load in the LUT file
% User selects the LUT:
[LUTfile, LUTpath] = uigetfile({'*.xlsx; *.csv'},'Select the LUT');
LUT = readcell(fullfile(LUTpath,LUTfile));
% User selects the folder containing avis
data_dir_path = uigetdir('.','Select directory containing input data');
% Find the files within the chosen directory:
data_dir = dir(data_dir_path);
temp = data_dir;
% Fix the DOS era issue with the dir function (loads in the parent
% directories '.' and '..')
data_dir = temp(~ismember({temp.name}, {'.', '..'}));
fname_list = {data_dir.name}';
%% Reading in information from LUT file and loading data
% loop to go through each file in folder
for i = (1:length(data_dir))
% finds files that are confocal
if contains(data_dir(i).name, 'CON', IgnoreCase=true)
% extracts the video number from the avi name
vid_num = str2double(data_dir(i).name(end-6:end-4));
% extracts which index that video number is on for the lut file
index = find([LUT{:,1}] == vid_num);
% extracts the fov from the LUT
fov = LUT{index, 5};
% creates the variable we need to match what is normally in the mat
% file and extracted from ARFS
optical_scanners_settings.raster_scanner_amplitude_in_deg = fov;
save(fullfile(data_dir_path, strcat(data_dir(i).name(1:end-4), '.mat')), "optical_scanners_settings");
end
end