diff --git a/tests/TestDeepInterpolationDataStore.m b/tests/TestDeepInterpolationDataStore.m index da8d39f..0551964 100644 --- a/tests/TestDeepInterpolationDataStore.m +++ b/tests/TestDeepInterpolationDataStore.m @@ -18,7 +18,7 @@ %% Test 01: Check if matlab.io.Datastore is superclass. % A deepinterpolation datastore inherits from abstract Datastore -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); assert(isa(dids,'matlab.io.Datastore')); %% Test 02: Call the read @@ -30,7 +30,7 @@ % The first frame that allows that is the 32nd! % The combination of training data and center frame is called a "set" here, and the % number of sets, following the logic above, is N-Frames - 62. -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); t = read(dids); assert(iscell(t)); assert(numel(t) == 2); @@ -39,7 +39,7 @@ %% Test 03: Call the read again % Standard sequential datastore behavior: advance to "second" center-frame -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); [t,info] = read(dids); assert(iscell(t)); @@ -50,7 +50,7 @@ %% Test 04: Successfully read until no more data % The testdatastack should return 38 sets of training frames and reference frame -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); count = 0; while(hasdata(dids)) read(dids); @@ -59,7 +59,7 @@ assert(count == 38); %% Test 05: Call read when out of data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); try read(dids); catch ME @@ -69,12 +69,12 @@ %% Test 11: Call the readall method % Standard sequential datastore behavior: return all data in a nx2 Cell array, for % the test dataset n==38 -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); allt = readall(dids); assert(all(size(allt)==[38 2])); %% Test 12: Call the readall method when out of data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); while(hasdata(dids)) read(dids); end @@ -83,7 +83,7 @@ %% Test 21: Call the reset method before any read % Reset to "first" frame (in fact, the 32nd frame in the stack...) -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); reset(dids); [t,info] = read(dids); assert(iscell(t)); @@ -93,7 +93,7 @@ assert(info == "set=1/centerframe=32"); %% Test 22: Call the reset method after some reads -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); read(dids); read(dids); @@ -106,7 +106,7 @@ assert(info == "set=1/centerframe=32"); %% Test 23: Call the reset method after readall -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); tall = readall(dids); reset(dids); @@ -118,7 +118,7 @@ assert(info == "set=1/centerframe=32"); %% Test 24: Call the reset method when out of data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); while(hasdata(dids)) read(dids); end @@ -131,24 +131,24 @@ assert(info == "set=1/centerframe=32"); %% Test 31: Call the progress method before any reads -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); p = progress(dids); assert(p==0); %% Test 32: Call the progress method after readall but before read. -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); readall(dids); p = progress(dids); assert(p==0); %% Test 33: Call the progress method after read -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); p = progress(dids); assert((p-0.0270)<1e-4); %% Test 34: Call the progress method when out of data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); while(hasdata(dids)) read(dids); end @@ -156,7 +156,7 @@ assert((p-1.0)<1e-4); %% Test 35: Progress produces correct output over all sets -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); idx = 1; while(hasdata(dids)) p(idx) = progress(dids); @@ -168,7 +168,7 @@ assert(all(diff(p) > 0), "progress must be monotonically increasing"); %% Test 41: Preview methods returns first set -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); t = preview(dids); assert(iscell(t)); assert(numel(t) == 2); @@ -177,7 +177,7 @@ assert((t{1}(323,23,44)-138)<1e-4); %% Test 42: Preview methods returns first set after reads -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); read(dids); t = preview(dids); @@ -188,7 +188,7 @@ assert((t{1}(323,23,44)-138)<1e-4); %% Test 43: Preview methods returns first set after readall -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); readall(dids); t = preview(dids); assert(iscell(t)); @@ -198,7 +198,7 @@ assert((t{1}(323,23,44)-138)<1e-4); %% Test 44: Preview methods returns first set after reads and reset -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); read(dids); reset(dids); @@ -210,7 +210,7 @@ assert((t{1}(323,23,44)-138)<1e-4); %% Test 45: Preview methods returns first set when out of data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); while hasdata(dids) read(dids); end @@ -222,7 +222,7 @@ assert((t{1}(323,23,44)-138)<1e-4); %% Test 46: Read after preview is from correct location -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); read(dids); preview(dids); @@ -234,13 +234,13 @@ assert(info == "set=3/centerframe=34"); %% Test 47: Readall after preview works correctly -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); preview(dids); allt = readall(dids); assert(all(size(allt)==[38 2])); %% Test 48: Hasdata works correctly after preview -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); read(dids); preview(dids); assert(hasdata(dids)); @@ -249,22 +249,22 @@ % A partition of the deepinterpolation datastore is merely pointing to a different % startframe and has a smaller number of available sets. All the other behaviors are % derived from that -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,10,7); assert(isa(subds,'matlab.io.Datastore')); %% Test 51: Call Partition, check if the partition has correct properties -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,10,7); assert(isequal(properties(dids),properties(subds))); %% Test 52: Call Partition, check if the partition has correct methods -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,10,7); assert(isequal(methods(dids),methods(subds))); %% Test 53: Call Partition, successfully read from a partition -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,10,7); [t,info] = read(subds); assert(iscell(t)); @@ -274,14 +274,14 @@ assert(info == "set=1/centerframe=56"); %% Test 54: Call last Partition, read all data -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,13,13); while hasdata(subds) read(subds); end %% Test 55: Call Partition, check that total number of sets/frames is correct -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); partsets = 0; for iii = 1:10 subds = partition(dids,10,iii); @@ -290,7 +290,7 @@ assert(partsets-38 < 1e-4); %% Test 56: Call partition with partition=1 and index=1 and validate -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,1,1); assert(isequal(properties(dids),properties(subds))); assert(isequal(methods(dids),methods(subds))); @@ -298,7 +298,7 @@ assert(isequaln(preview(subds),preview(dids))); %% Test 57: Partition a partition again and validate -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,2,2); subsubds = partition(subds,2,2); [t,info] = read(subsubds); @@ -309,7 +309,7 @@ assert(info == "set=1/centerframe=61"); %% Test 58: Progress is working correctly in partitions -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = partition(dids,2,2); idx = 1; clear p @@ -327,7 +327,7 @@ %% Test 60: Create a Subset of the datastore and validate % deepinterpolation datastore is subsettable, again this just assigns the correct % startframe and number of available sets, but points to the same file -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = subset(dids,5:20); [t,info]=read(subds); assert(iscell(t)); @@ -337,7 +337,7 @@ assert(info == "set=1/centerframe=36"); %% Test 61: Progress is working correctly in subsets -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); subds = subset(dids,5:10); idx = 1; clear p @@ -354,14 +354,14 @@ %% Test 71: Fail on wrong image size try - dids = DeepInterpolationDataStore(WRONGSIZETESTSTACKFULLFILE); %#ok + dids = deepinterp.Datastore(WRONGSIZETESTSTACKFULLFILE); %#ok catch EM assert(strcmp(EM.message,'Actual frame size is not equal to specified outputFrameSize'),"Fail on wrong tiff size"); end %% Test 72: Read data with automatic resize options.doAutoResize = true; -dids = DeepInterpolationDataStore(WRONGSIZETESTSTACKFULLFILE, options); +dids = deepinterp.Datastore(WRONGSIZETESTSTACKFULLFILE, options); t = read(dids); assert(iscell(t)); assert(numel(t) == 2); @@ -369,12 +369,12 @@ assert(all((size(t{2})==[512 512]))); %% Test 81: Shuffling returns randomized datastore without error -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); shds = shuffle(dids); assert(isa(shds,'matlab.io.Datastore')); %% Test 82: can read sequentially from shuffled datastore -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); shds = shuffle(dids); count = 0; while(hasdata(shds)) @@ -384,7 +384,7 @@ assert(count == 38); %% Test 83: can read all from shuffled datastore -dids = DeepInterpolationDataStore(TESTSTACKFULLFILE); +dids = deepinterp.Datastore(TESTSTACKFULLFILE); shds = shuffle(dids); allt = readall(shds); -assert(all(size(allt)==[38 2])); \ No newline at end of file +assert(all(size(allt)==[38 2]));