-
Notifications
You must be signed in to change notification settings - Fork 0
/
getImagePositions.m
69 lines (50 loc) · 2.16 KB
/
getImagePositions.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
59
60
61
62
63
64
65
66
67
%%
projectPath = '/Users/benjaminemert/Dropbox (RajLab)/Shared_Ben/timeMachine/';
dataPath = 'rawdata/TM31CarbonCopy/plate3';
extractionPath = 'extractedData/TM31CarbonCopy/GFP';
if ~exist(extractionPath, 'dir')
mkdir(extractionPath)
end
cd(dataPath);
wells = {'wellA1', 'wellA2','wellA3','wellB1','wellB2','wellB3'};
groups = {'onTarget', 'offTarget'};
%%
allData = {};
for i = 1:numel(wells)
for ii = 1:numel(groups)
if exist(sprintf('%s/round1/%s', wells{i}, groups{ii}), 'dir')
inDir = sprintf('%s/round1/%s', wells{i}, groups{ii});
inFiles = dir(sprintf('%s/*.nd2',inDir));
inFiles = {inFiles.name};
wellData = {};
counter = 1;
for iii = 1:numel(inFiles)
reader = bfGetReader(fullfile(inDir, inFiles{iii}));
omeMeta = reader.getMetadataStore();
arrayNums = [];
XPos = [];
YPos = [];
imageCount = omeMeta.getImageCount;
for iv = 1:imageCount
arrayNums = [arrayNums, counter];
XPos = [XPos, double(omeMeta.getPlanePositionX(iv-1,0).value())];
YPos = [YPos, double(omeMeta.getPlanePositionY(iv-1,0).value())];
counter = counter + 1;
end
plate = cell(1, imageCount);
[plate{:}] = deal('plate3');
well = cell(1, imageCount);
[well{:}] = deal(wells{i});
type = cell(1, imageCount);
[type{:}] = deal(groups{ii});
fileData = horzcat(num2cell(arrayNums'), num2cell(XPos'), num2cell(YPos'), plate', well', type');
wellData = vertcat(wellData, fileData);
end
allData = vertcat(allData, wellData);
end
end
end
%%
allDataTable = cell2table(allData);
allDataTable.Properties.VariableNames = {'objArrayNum', 'XPos', 'YPos', 'plate', 'well', 'type'};
writetable(allDataTable, fullfile(projectPath, 'extractedData/TM31CarbonCopy/RNAFISH/WM989_plate3_RNAFISH_positions.csv'));