Skip to content

Commit 6ace963

Browse files
committed
Reexport ophys tutorial
1 parent 4360382 commit 6ace963

5 files changed

Lines changed: 62 additions & 41 deletions

File tree

docs/source/_static/html/tutorials/ophys.html

Lines changed: 35 additions & 28 deletions
Large diffs are not rendered by default.
-13 Bytes
Loading

docs/source/pages/tutorials/ophys.rst

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -503,11 +503,7 @@ Finally, read back the image/pixel masks and display the first 10 RoIs in a figu
503503
end
504504
end
505505
506-
% Create one distinct color per ROI
507-
cmap = lines(num_rois);
508-
509-
% Convert label image to RGB
510-
rgb_image = label2rgb(label_image, cmap, 'k', 'shuffle');
506+
rgb_image = convertLabelImage2RGBImage(label_image); % Local helper function
511507
512508
imshow(rgb_image)
513509
title(sprintf('First %d ROIs', 10))
@@ -543,8 +539,8 @@ See our tutorials for more details about your data type:
543539
* `Extensions <https://pynwb.readthedocs.io/en/stable/tutorials/general/extensions.html#sphx-glr-tutorials-general-extensions-py>`_
544540
* `Advanced HDF5 I/O <https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/h5dataio.html#sphx-glr-tutorials-advanced-io-h5dataio-py>`_
545541

546-
... Helper functions ...
547-
------------------------
542+
Helper functions
543+
----------------
548544

549545
.. code-block:: matlab
550546
@@ -584,3 +580,14 @@ See our tutorials for more details about your data type:
584580
data(i, :) = baseline + response + noise;
585581
end
586582
end
583+
584+
function rgbImage = convertLabelImage2RGBImage(labelImage)
585+
numLabels = numel(unique(labelImage(labelImage>0)));
586+
587+
% Create one distinct color per label
588+
cmap = lines(numLabels);
589+
590+
% Convert label image to RGB
591+
map = [0 0 0; cmap]; % black for background plus label colors
592+
rgbImage = reshape(map(labelImage(:)+1, :), [size(labelImage), 3]);
593+
end

tutorials/ophys.mlx

-15.5 KB
Binary file not shown.

tutorials/private/mcode/ophys.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,7 @@
406406
end
407407
end
408408

409-
% Create one distinct color per ROI
410-
cmap = lines(num_rois);
411-
412-
% Convert label image to RGB
413-
rgb_image = label2rgb(label_image, cmap, 'k', 'shuffle');
409+
rgb_image = convertLabelImage2RGBImage(label_image); % Local helper function
414410

415411
imshow(rgb_image)
416412
title(sprintf('First %d ROIs', 10))
@@ -438,7 +434,7 @@
438434
% Extensions>
439435
% * <https://pynwb.readthedocs.io/en/stable/tutorials/advanced_io/h5dataio.html#sphx-glr-tutorials-advanced-io-h5dataio-py
440436
% Advanced HDF5 I/O>
441-
%% ... Helper functions ...
437+
%% Helper functions
442438

443439
function X = generateCenterCoords(varargin)
444440
% Use reproducible random number generation for consistent
@@ -475,4 +471,15 @@
475471

476472
data(i, :) = baseline + response + noise;
477473
end
474+
end
475+
476+
function rgbImage = convertLabelImage2RGBImage(labelImage)
477+
numLabels = numel(unique(labelImage(labelImage>0)));
478+
479+
% Create one distinct color per label
480+
cmap = lines(numLabels);
481+
482+
% Convert label image to RGB
483+
map = [0 0 0; cmap]; % black for background plus label colors
484+
rgbImage = reshape(map(labelImage(:)+1, :), [size(labelImage), 3]);
478485
end

0 commit comments

Comments
 (0)