forked from AllenInstitute/render-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel.py
More file actions
54 lines (47 loc) · 1.66 KB
/
channel.py
File metadata and controls
54 lines (47 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
from .image_pyramid import ImagePyramid
class Channel:
'''class for storing channels of different mipmapsources'''
def __init__(self, name=None, maxIntensity=None, minIntensity=None,
ip=None, json=None):
'''
Parameters
==========
name: str
name of channel
maxIntensity: int
maximum intensity to display (optional)
minIntensity: int
minimum default intensity to display (optional)
ip: ImagePyramid
set of mipmaplevel images for this channel
json: dict
json representation of this channel
'''
if json is not None:
self.from_dict(json)
else:
self.name = name
self.maxIntensity = maxIntensity
self.minIntensity = minIntensity
self.ip = ip
def to_dict(self):
'''method for serializing this class to a json compatible dictionary'''
d = {}
d['name'] = self.name
if self.minIntensity is not None:
d['minIntensity'] = self.minIntensity
if self.maxIntensity is not None:
d['maxIntensity'] = self.maxIntensity
d['mipmapLevels'] = self.ip.to_dict()
return d
def from_dict(self, d):
'''method for deserializing this class from a json compatible dictionary
Parameters
==========
d: dict
json compatible dictionary representation of this channel
'''
self.name = d['name']
self.minIntensity = d['minIntensity']
self.maxIntensity = d['maxIntensity']
self.ip = ImagePyramid.from_dict(d['mipmapLevels'])