-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeed_Selector.m
More file actions
123 lines (95 loc) · 3.58 KB
/
Copy pathSeed_Selector.m
File metadata and controls
123 lines (95 loc) · 3.58 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
% OCT Seed Selector
% Created by: Jenna Grieshop
% Date created: 7/29/2025
%
% Purpose: To allow user to select the seed point for the image so that it
% can be used with the thickness extractor in a separate step
%
% Requirements: LUT file with the filenames and lateral scale
% information (px/deg, mpp). If you do not have this, select cancel when
% prompted and a new LUT will be generated from this script.
%
% Inputs: prompt for LUT file, prompt for unit selection, prompt
% to select "seed" on image of approximate 0 (center of the ONH)
%
% Outputs: An excel file with the seed point will be generated or if one
% exists in the folder the information will be added to the LUT file
%
clear all
close all
clc
new_lut = 0;
FileName = strings(0);
AxialScale = [];
LateralScale = [];
Seed = [];
LUT_new = table(FileName, AxialScale, LateralScale, Seed);
data = [];
vert_scale_list = {'R2200: 1.6126umpp', 'R2310: 2.4533umpp', 'EnFocus: 5.4076umpp', 'Other (manual entry)'};
% User selects the data directory
data_dir_path = uigetdir('.','Select directory');
% User selects the LUT
try
[LUTfile, LUTpath] = uigetfile('.csv','Select the Seed LUT, if none - cancel');
LUT = readtable(fullfile(LUTpath,LUTfile), Delimiter=',');
catch
new_lut = 1;
LUT = table(FileName, AxialScale, LateralScale, Seed);
end
% Need to check what kind of data is in the directory and set a flag to
% operate accordingly - JG generalize
% Get directory of just the .mat files
data_dir_mat = dir(fullfile(data_dir_path, '*.mat'));
% Get list of .mat file names
for i=1:length(data_dir_mat)
mat_list{i} = data_dir_mat(i).name;
end
mat_list = string(mat_list);
% if a new LUT is needed, all files are missing, else find what files are
% missing from LUT that exist in the directory
if new_lut == 1
missing_from_LUT = mat_list;
else
lut_list = string(LUT{:,1});
missing_from_LUT = setdiff(mat_list, lut_list);
end
% Find and add all info to LUT for missing entries
for j=1: length(missing_from_LUT)
% Get the corresponding image path for the .mat file
image_path = strrep(missing_from_LUT(j), '.mat', '.tif');
% open and show the image
image = imshow(imread(fullfile(data_dir_path, image_path)));
title(missing_from_LUT(j), 'Interpreter', 'none');
set(gcf, 'units','normalized','outerposition',[0 0 1 1]); % make the image full screen
% find approximate 0 with user selected seed
% draw seed point
seed = drawpoint;
% seed pixel coordinate
seed_px(j) = round(seed.Position(1));
close
% User to select the vertical scale
[indx_unit,tf1] = listdlg('PromptString','Select OCT axial(vertical) scale', 'SelectionMode', 'single', 'ListString', vert_scale_list);
% Set the vertical scale based on user's choice
if tf1 == 1
if indx_unit ==1
vert(j) = 1.6126;
elseif indx_unit == 2
vert(j) = 2.4533;
elseif indx_unit == 3
vert(j) = 5.4076;
elseif indx_unit == 4
m = 'Please enter the axial(vertical) scale in microns per pixel: ';
temp = inputdlg(m);
vert(j) = str2double(temp{1});
end
end
% Prompt user to enter the lateral scale
m = 'Please enter the lateral scale in pixel per degree: ';
temp2 = inputdlg(m);
lat(j) = str2double(temp2{1});
data = [data; missing_from_LUT(j), vert(j), lat(j), seed_px(j)];
end
% Add new data to LUT
LUT_new = [LUT; cellstr(data)];
% Save LUT
writetable(LUT_new, fullfile(data_dir_path, strcat("Seed_LUT_", string(datetime('now','TimeZone','local','Format','yyyyMMdd')), ".csv")));