Skip to content

Commit 6816f59

Browse files
committed
Merge pull request #67 from cneves/ticket/12037_makemovie_channeldefs
Allow passing extra channel rendering options to Make_Movie script (see ...
2 parents 4e28e22 + 9bdcc71 commit 6816f59

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

omero/export_scripts/Make_Movie.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,13 @@
6767
import numpy
6868
import omero.util.pixelstypetopython as pixelstypetopython
6969
from struct import unpack
70-
from omero.rtypes import wrap, rstring, rlong, rint, robject
70+
from omero.rtypes import wrap, rstring, rint, rlong, robject
7171
from omero.gateway import BlitzGateway
7272
from omero.constants.namespaces import NSCREATED
7373
from omero.constants.metadata import NSMOVIE
7474

7575
from cStringIO import StringIO
76+
from types import StringTypes
7677

7778
try:
7879
from PIL import Image, ImageDraw # see ticket:2597
@@ -287,6 +288,8 @@ def validChannels(set, sizeC):
287288
if(len(set) == 0):
288289
return False
289290
for val in set:
291+
if isinstance(val, StringTypes):
292+
val = int(val.split('|')[0].split('$')[0])
290293
if(val < 0 or val > sizeC):
291294
return False
292295
return True
@@ -499,7 +502,21 @@ def writeMovie(commandArgs, conn):
499502
commandArgs["Scalebar"] = 0
500503

501504
cRange = range(0, sizeC)
502-
if "Channels" in commandArgs and \
505+
cWindows = None
506+
cColours = None
507+
if "ChannelsExtended" in commandArgs and \
508+
validChannels(commandArgs["ChannelsExtended"], sizeC):
509+
cRange = []
510+
cWindows = []
511+
cColours = []
512+
for c in commandArgs["ChannelsExtended"]:
513+
m = re.match('^(?P<i>\d+)(\|(?P<ws>\d+)' +
514+
'\:(?P<we>\d+))?(\$(?P<c>.+))?$', c)
515+
if m is not None:
516+
cRange.append(int(m.group('i'))-1)
517+
cWindows.append([float(m.group('ws')), float(m.group('we'))])
518+
cColours.append(m.group('c'))
519+
elif "Channels" in commandArgs and \
503520
validChannels(commandArgs["Channels"], sizeC):
504521
cRange = commandArgs["Channels"]
505522

@@ -513,7 +530,9 @@ def writeMovie(commandArgs, conn):
513530
commandArgs["Show_Time"] = False
514531

515532
frameNo = 1
516-
omeroImage.setActiveChannels(map(lambda x: x+1, cRange))
533+
omeroImage.setActiveChannels(map(lambda x: x+1, cRange),
534+
cWindows,
535+
cColours)
517536
renderingEngine = omeroImage._re
518537

519538
overlayColour = (255, 255, 255)
@@ -689,7 +708,13 @@ def __init__(self, name, optional = False, out = False, description =
689708
scripts.List(
690709
"Channels",
691710
description="The selected channels",
692-
grouping="5").ofType(rint(0)),
711+
grouping="5.1").ofType(rint(0)),
712+
713+
scripts.List(
714+
"ChannelsExtended",
715+
description="The selected channels, with optional range"
716+
" and colour. Takes precendence over Channels.",
717+
grouping="5.2").ofType(rstring('')),
693718

694719
scripts.Bool(
695720
"Show_Time",

0 commit comments

Comments
 (0)