Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit cd58668

Browse files
committed
Support arbitrary layer dataset in flatplot
1 parent 6937750 commit cd58668

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

flatmap/code/utils/flatplot.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -208,17 +208,16 @@ def str_to_reduction(s):
208208
data_valid = (dmsk.raw != 0)
209209
del dmsk
210210

211-
ldict = {1:'1', 2:'23', 4:'4', 5:'5', 6:'6'}
212-
if args.only_layer is not None:
213-
if args.only_layer not in ldict:
214-
raise ValueError("requested layer {} does not exist".format(args.only_layer))
215-
ldict = {args.only_layer: ldict[args.only_layer]}
216-
217211
lay = None
218212
if args.split or args.only_layer is not None:
219-
LOGGER.info('Loading layer annotation')
213+
LOGGER.info('Loading layer annotation "{}"'.format(args.layers))
220214
lay = VoxelData.load_nrrd(args.layers)
221215
assert(lay.shape == dat.shape)
216+
ldict = {x: x for x in np.unique(lay.raw)[1:]} # skip background first value (= 0)
217+
if args.only_layer is not None:
218+
if args.only_layer not in ldict:
219+
raise ValueError("requested layer {} does not exist".format(args.only_layer))
220+
ldict = {args.only_layer: ldict[args.only_layer]}
222221

223222
LOGGER.info('Masking data')
224223
mask = np.where(fmap_valid & data_valid)
@@ -229,7 +228,7 @@ def str_to_reduction(s):
229228
LOGGER.info('Masking layer annotation')
230229
layval = lay.raw[mask]
231230
for k, v in ldict.items():
232-
LOGGER.info('Generating and saving image for Layer{} ({}x{})'.format(v, args.flatpix, args.flatpix))
231+
LOGGER.info('Generating and saving image for Layer {} ({}x{})'.format(v, args.flatpix, args.flatpix))
233232
lmask = np.where(layval == k)
234233
img, agg = func(flatpos[lmask], flatval[lmask], cmap, args.flatpix, **kwargs)
235234
LOGGER.info('Min: {} Max: {}'.format(np.nanmin(agg.values), np.nanmax(agg.values)))

0 commit comments

Comments
 (0)