|
@@ -45,6 +45,37 @@ def print_metadata(nf, sec_type=None, sec_name=None, max_depth=-1):
|
|
|
s.pprint(max_depth=max_depth)
|
|
|
|
|
|
|
|
|
+def find_mtags_for_tag(block, tag):
|
|
|
+ """Finds the MultiTags (prepresentatives of the actual stimulus
|
|
|
+ outputs) that ran during a RePro run. Relacs makes sure that stimulations
|
|
|
+ with the same settings end up in the same MultiTag.
|
|
|
+
|
|
|
+ Arguments:
|
|
|
+ block --- nix.Block, the block in which to look for MultiTags
|
|
|
+ tag --- nix.Tag, the Tag (aka, the RepPro run) defining the search interval
|
|
|
+
|
|
|
+ Returns:
|
|
|
+ a list of MultiTags
|
|
|
+ a list of lists containing the position indices for the respective MultiTags
|
|
|
+ """
|
|
|
+ assert(isinstance(block, nix.pycore.block.Block))
|
|
|
+ assert(isinstance(tag, nix.pycore.tag.Tag))
|
|
|
+ mtags = []
|
|
|
+ positions = []
|
|
|
+ tag_start = np.atleast_1d(tag.position)
|
|
|
+ tag_end = tag_start + np.atleast_1d(tag.extent)
|
|
|
+ for mt in block.multi_tags:
|
|
|
+ mt_starts = np.atleast_1d(mt.positions[:])
|
|
|
+ mt_ends = mt_starts + np.atleast_1d(mt.extents[:])
|
|
|
+ pos = np.argwhere(mt_starts[(mt_starts > tag_start) &
|
|
|
+ (mt_starts < tag_end) &
|
|
|
+ (mt_ends <= tag_end)])[:, 0]
|
|
|
+ if len(pos) > 0:
|
|
|
+ mtags.append(mt)
|
|
|
+ positions.append(pos)
|
|
|
+ return mtags, positions
|
|
|
+
|
|
|
+
|
|
|
def data_overview(nf):
|
|
|
assert(nf and isinstance(nf, nix.pycore.file.File) and nf.is_open)
|
|
|
b = nf.blocks[0]
|
|
@@ -63,7 +94,23 @@ def data_overview(nf):
|
|
|
set_data = [da for da in b.data_arrays if da.dimensions[0].dimension_type == nix.DimensionType.Set]
|
|
|
for sd in set_data:
|
|
|
print("\t%s, size: %s" % (sd.name, str(sd.shape)))
|
|
|
+ print("\n")
|
|
|
+
|
|
|
+
|
|
|
+def stimulus_overview(nf):
|
|
|
+ assert(nf and isinstance(nf, nix.pycore.file.File) and nf.is_open)
|
|
|
+ b = nf.blocks[0]
|
|
|
|
|
|
+ print("Stimulations, aka RePro runs:")
|
|
|
+ repro_runs = [t for t in b.tags if "repro_run" in t.type]
|
|
|
+ for rr in repro_runs:
|
|
|
+ start = rr.position[0]
|
|
|
+ end = start + rr.extent[0]
|
|
|
+ print("\t RePro %s, time: %.4f --> %.4f%s" % (rr.name, start, end, rr.units[0]))
|
|
|
+ mts, positions = find_mtags_for_tag(b, rr)
|
|
|
+ for mt, pos in zip(mts, positions):
|
|
|
+ print("\t\t with %i stimulus repetitions" % (len(pos)))
|
|
|
+ print("\n")
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
@@ -77,4 +124,6 @@ if __name__ == "__main__":
|
|
|
|
|
|
data_overview(nix_file)
|
|
|
|
|
|
+ stimulus_overview(nix_file)
|
|
|
+
|
|
|
nix_file.close()
|