Skip to content

Commit d88fc68

Browse files
Merge pull request #58 from MATLAB-Community-Toolboxes-at-INCF/enpack-datastore
Relocate custom datastore to root namespace
2 parents 035afed + 618fc44 commit d88fc68

File tree

6 files changed

+49
-48
lines changed

6 files changed

+49
-48
lines changed

datastore/DeepInterpolationDataStore.m renamed to +deepinterp/Datastore.m

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
classdef DeepInterpolationDataStore < matlab.io.Datastore & ...
1+
classdef Datastore < matlab.io.Datastore & ...
22
matlab.io.datastore.Subsettable & ...
33
matlab.io.datastore.Shuffleable
4-
%DEEPINTERPOLATIONDATASTORE - custom datastore for DeepInterpolation-MATLAB
4+
% DATASTORE - custom datastore for DeepInterpolation-MATLAB
55
%
66
% This custom datastore provides flanking frames and the center frame
77
% upon one read.
88
%
9-
% dids = DeepInterpolationDataStore(pathToTiffFile, options);
9+
% dids = deepinterp.Datastore(pathToTiffFile, options);
1010
%
1111
% Input must be full path to a grayscale, single channel tiff stack of
1212
% >'flankingFrames + 2' frames in order to work (this is according to
@@ -36,7 +36,7 @@
3636
end
3737

3838
methods % begin methods section
39-
function myds = DeepInterpolationDataStore(filePath, options)
39+
function myds = Datastore(filePath, options)
4040
arguments
4141
filePath
4242
options = struct();
@@ -257,4 +257,4 @@ function reset(myds)
257257

258258
end
259259

260-
end
260+
end

+deepinterp/setup.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ function setup()
1212
addpath(fullfile(tbd, "sampleData"))
1313
addpath(fullfile(tbd, "pretrainedModels"))
1414
addpath(fullfile(tbd, "examples"))
15-
addpath(fullfile(tbd, "datastore"))
15+
1616

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The principle behind DeepInterpolation is illustrated in the following figure fr
5656
![Figure 1a from Lecoq et al. 2021](sampleData/Lecoq_et_al_2021_Fig1a.png).
5757
-->
5858

59-
To predict the frame-of-interest ("predicted frame"), a deep learning network uses data from several preceeding and succeeding video frames. During training, the network is modified so that it produces better and better representations of the predicted frames over several datasets. During inference, the network produces predicted frames that are used in place of the original data. If the signal in the data is well predicted by the information in the preceeding and succeeding frames, then the inferred data contains a reconstruction of the original data where the usual noise that occurs independently on each frame is greatly reduced, because it is not predicted on average. The signal can be inferred with high quality in part because the network can average out the independent noise in the preceeding and succeeding frames to uncover the underlying signal just prior to and just after the signal in the predicted frame.
59+
To predict the frame-of-interest ("predicted frame"), a deep learning network uses data from several preceeding and succeeding video frames. During training, the network is modified so that it produces better and better representations of the predicted frames over several datasets. During inference, the network produces predicted frames that are used in place of the original data. DeepInterpolation works well in situations where the signal in the data is well predicted by the information in the preceeding and succeeding frames. In these cases, the inferred data contains a good reconstruction of the underlying signal while the noise that occurs independently on each frame is greatly reduced, because the noise is not predicted on average.
6060

6161
### Installation
6262
🚧

examples/tiny_ophys_training.mlx

478 KB
Binary file not shown.

tests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

datastore/test/TestDeepInterpolationDataStore.m renamed to tests/TestDeepInterpolationDataStore.m

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
%% Test 01: Check if matlab.io.Datastore is superclass.
2020
% A deepinterpolation datastore inherits from abstract Datastore
21-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
21+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
2222
assert(isa(dids,'matlab.io.Datastore'));
2323

2424
%% Test 02: Call the read
@@ -30,7 +30,7 @@
3030
% The first frame that allows that is the 32nd!
3131
% The combination of training data and center frame is called a "set" here, and the
3232
% number of sets, following the logic above, is N-Frames - 62.
33-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
33+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
3434
t = read(dids);
3535
assert(iscell(t));
3636
assert(numel(t) == 2);
@@ -39,7 +39,7 @@
3939

4040
%% Test 03: Call the read again
4141
% Standard sequential datastore behavior: advance to "second" center-frame
42-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
42+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
4343
read(dids);
4444
[t,info] = read(dids);
4545
assert(iscell(t));
@@ -50,7 +50,7 @@
5050

5151
%% Test 04: Successfully read until no more data
5252
% The testdatastack should return 38 sets of training frames and reference frame
53-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
53+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
5454
count = 0;
5555
while(hasdata(dids))
5656
read(dids);
@@ -59,7 +59,7 @@
5959
assert(count == 38);
6060

6161
%% Test 05: Call read when out of data
62-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
62+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
6363
try
6464
read(dids);
6565
catch ME
@@ -69,12 +69,12 @@
6969
%% Test 11: Call the readall method
7070
% Standard sequential datastore behavior: return all data in a nx2 Cell array, for
7171
% the test dataset n==38
72-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
72+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
7373
allt = readall(dids);
7474
assert(all(size(allt)==[38 2]));
7575

7676
%% Test 12: Call the readall method when out of data
77-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
77+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
7878
while(hasdata(dids))
7979
read(dids);
8080
end
@@ -83,7 +83,7 @@
8383

8484
%% Test 21: Call the reset method before any read
8585
% Reset to "first" frame (in fact, the 32nd frame in the stack...)
86-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
86+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
8787
reset(dids);
8888
[t,info] = read(dids);
8989
assert(iscell(t));
@@ -93,7 +93,7 @@
9393
assert(info == "set=1/centerframe=32");
9494

9595
%% Test 22: Call the reset method after some reads
96-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
96+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
9797
read(dids);
9898
read(dids);
9999
read(dids);
@@ -106,7 +106,7 @@
106106
assert(info == "set=1/centerframe=32");
107107

108108
%% Test 23: Call the reset method after readall
109-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
109+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
110110
read(dids);
111111
tall = readall(dids);
112112
reset(dids);
@@ -118,7 +118,7 @@
118118
assert(info == "set=1/centerframe=32");
119119

120120
%% Test 24: Call the reset method when out of data
121-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
121+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
122122
while(hasdata(dids))
123123
read(dids);
124124
end
@@ -131,32 +131,32 @@
131131
assert(info == "set=1/centerframe=32");
132132

133133
%% Test 31: Call the progress method before any reads
134-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
134+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
135135
p = progress(dids);
136136
assert(p==0);
137137

138138
%% Test 32: Call the progress method after readall but before read.
139-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
139+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
140140
readall(dids);
141141
p = progress(dids);
142142
assert(p==0);
143143

144144
%% Test 33: Call the progress method after read
145-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
145+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
146146
read(dids);
147147
p = progress(dids);
148148
assert((p-0.0270)<1e-4);
149149

150150
%% Test 34: Call the progress method when out of data
151-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
151+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
152152
while(hasdata(dids))
153153
read(dids);
154154
end
155155
p = progress(dids);
156156
assert((p-1.0)<1e-4);
157157

158158
%% Test 35: Progress produces correct output over all sets
159-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
159+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
160160
idx = 1;
161161
while(hasdata(dids))
162162
p(idx) = progress(dids);
@@ -168,7 +168,7 @@
168168
assert(all(diff(p) > 0), "progress must be monotonically increasing");
169169

170170
%% Test 41: Preview methods returns first set
171-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
171+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
172172
t = preview(dids);
173173
assert(iscell(t));
174174
assert(numel(t) == 2);
@@ -177,7 +177,7 @@
177177
assert((t{1}(323,23,44)-138)<1e-4);
178178

179179
%% Test 42: Preview methods returns first set after reads
180-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
180+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
181181
read(dids);
182182
read(dids);
183183
t = preview(dids);
@@ -188,7 +188,7 @@
188188
assert((t{1}(323,23,44)-138)<1e-4);
189189

190190
%% Test 43: Preview methods returns first set after readall
191-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
191+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
192192
readall(dids);
193193
t = preview(dids);
194194
assert(iscell(t));
@@ -198,7 +198,7 @@
198198
assert((t{1}(323,23,44)-138)<1e-4);
199199

200200
%% Test 44: Preview methods returns first set after reads and reset
201-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
201+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
202202
read(dids);
203203
read(dids);
204204
reset(dids);
@@ -210,7 +210,7 @@
210210
assert((t{1}(323,23,44)-138)<1e-4);
211211

212212
%% Test 45: Preview methods returns first set when out of data
213-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
213+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
214214
while hasdata(dids)
215215
read(dids);
216216
end
@@ -222,7 +222,7 @@
222222
assert((t{1}(323,23,44)-138)<1e-4);
223223

224224
%% Test 46: Read after preview is from correct location
225-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
225+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
226226
read(dids);
227227
read(dids);
228228
preview(dids);
@@ -234,13 +234,13 @@
234234
assert(info == "set=3/centerframe=34");
235235

236236
%% Test 47: Readall after preview works correctly
237-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
237+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
238238
preview(dids);
239239
allt = readall(dids);
240240
assert(all(size(allt)==[38 2]));
241241

242242
%% Test 48: Hasdata works correctly after preview
243-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
243+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
244244
read(dids);
245245
preview(dids);
246246
assert(hasdata(dids));
@@ -249,22 +249,22 @@
249249
% A partition of the deepinterpolation datastore is merely pointing to a different
250250
% startframe and has a smaller number of available sets. All the other behaviors are
251251
% derived from that
252-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
252+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
253253
subds = partition(dids,10,7);
254254
assert(isa(subds,'matlab.io.Datastore'));
255255

256256
%% Test 51: Call Partition, check if the partition has correct properties
257-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
257+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
258258
subds = partition(dids,10,7);
259259
assert(isequal(properties(dids),properties(subds)));
260260

261261
%% Test 52: Call Partition, check if the partition has correct methods
262-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
262+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
263263
subds = partition(dids,10,7);
264264
assert(isequal(methods(dids),methods(subds)));
265265

266266
%% Test 53: Call Partition, successfully read from a partition
267-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
267+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
268268
subds = partition(dids,10,7);
269269
[t,info] = read(subds);
270270
assert(iscell(t));
@@ -274,14 +274,14 @@
274274
assert(info == "set=1/centerframe=56");
275275

276276
%% Test 54: Call last Partition, read all data
277-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
277+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
278278
subds = partition(dids,13,13);
279279
while hasdata(subds)
280280
read(subds);
281281
end
282282

283283
%% Test 55: Call Partition, check that total number of sets/frames is correct
284-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
284+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
285285
partsets = 0;
286286
for iii = 1:10
287287
subds = partition(dids,10,iii);
@@ -290,15 +290,15 @@
290290
assert(partsets-38 < 1e-4);
291291

292292
%% Test 56: Call partition with partition=1 and index=1 and validate
293-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
293+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
294294
subds = partition(dids,1,1);
295295
assert(isequal(properties(dids),properties(subds)));
296296
assert(isequal(methods(dids),methods(subds)));
297297
assert(isequaln(read(subds),read(dids)));
298298
assert(isequaln(preview(subds),preview(dids)));
299299

300300
%% Test 57: Partition a partition again and validate
301-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
301+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
302302
subds = partition(dids,2,2);
303303
subsubds = partition(subds,2,2);
304304
[t,info] = read(subsubds);
@@ -309,7 +309,7 @@
309309
assert(info == "set=1/centerframe=61");
310310

311311
%% Test 58: Progress is working correctly in partitions
312-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
312+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
313313
subds = partition(dids,2,2);
314314
idx = 1;
315315
clear p
@@ -327,7 +327,7 @@
327327
%% Test 60: Create a Subset of the datastore and validate
328328
% deepinterpolation datastore is subsettable, again this just assigns the correct
329329
% startframe and number of available sets, but points to the same file
330-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
330+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
331331
subds = subset(dids,5:20);
332332
[t,info]=read(subds);
333333
assert(iscell(t));
@@ -337,7 +337,7 @@
337337
assert(info == "set=1/centerframe=36");
338338

339339
%% Test 61: Progress is working correctly in subsets
340-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
340+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
341341
subds = subset(dids,5:10);
342342
idx = 1;
343343
clear p
@@ -354,27 +354,27 @@
354354

355355
%% Test 71: Fail on wrong image size
356356
try
357-
dids = DeepInterpolationDataStore(WRONGSIZETESTSTACKFULLFILE); %#ok<NASGU>
357+
dids = deepinterp.Datastore(WRONGSIZETESTSTACKFULLFILE); %#ok<NASGU>
358358
catch EM
359359
assert(strcmp(EM.message,'Actual frame size is not equal to specified outputFrameSize'),"Fail on wrong tiff size");
360360
end
361361

362362
%% Test 72: Read data with automatic resize
363363
options.doAutoResize = true;
364-
dids = DeepInterpolationDataStore(WRONGSIZETESTSTACKFULLFILE, options);
364+
dids = deepinterp.Datastore(WRONGSIZETESTSTACKFULLFILE, options);
365365
t = read(dids);
366366
assert(iscell(t));
367367
assert(numel(t) == 2);
368368
assert(all((size(t{1})==[512 512 60])));
369369
assert(all((size(t{2})==[512 512])));
370370

371371
%% Test 81: Shuffling returns randomized datastore without error
372-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
372+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
373373
shds = shuffle(dids);
374374
assert(isa(shds,'matlab.io.Datastore'));
375375

376376
%% Test 82: can read sequentially from shuffled datastore
377-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
377+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
378378
shds = shuffle(dids);
379379
count = 0;
380380
while(hasdata(shds))
@@ -384,7 +384,7 @@
384384
assert(count == 38);
385385

386386
%% Test 83: can read all from shuffled datastore
387-
dids = DeepInterpolationDataStore(TESTSTACKFULLFILE);
387+
dids = deepinterp.Datastore(TESTSTACKFULLFILE);
388388
shds = shuffle(dids);
389389
allt = readall(shds);
390-
assert(all(size(allt)==[38 2]));
390+
assert(all(size(allt)==[38 2]));

0 commit comments

Comments
 (0)