<meta charset="utf-8"><span class="Apple-style-span" style="border-collapse: collapse; font-family: arial, sans-serif; font-size: 13px; "><div>I'm in the process of developing the first OMERO interface from <a href="http://cellprofiler.org/" target="_blank" style="color: rgb(64, 100, 128); ">CellProfiler 2.0</a>, and I'd like a little help in writing clean efficient code. The first module I'm working on is one that will import image channels into CP directly from OMERO.</div>
<div><br></div><div>From a user point of view, the controls will look like this:</div><blockquote style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><b>server</b>: <u>my server</u></div><div><b>username</b>: <u>afraser</u></div><div><b>password</b>: <u>*****</u></div><div><b>project</b>: <u>adams_project</u></div><div><b>dataset</b>: <u>adams_dataset</u></div></blockquote>
<div><br></div><div>...and they'll specify a name for each of their channels somehow:</div><blockquote style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 40px; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">
<div><b>channel 1 name</b>: <u>DNA</u></div><div><b>channel 2 name</b>: <u>Actin</u></div><div>(add channel button)</div></blockquote><div>(these names will be used in the input controls of downstream modules in CellProfiler)</div>
<div><br></div><div>Just before the pipeline is run, I'd like to connect to the server, and create a list of all the image ids that I'll be accessing during each iteration. One way to do this would be:</div><div>
<br>
</div><div><div><font face="'courier new', monospace"> c = omero.client(self.server.value)</font></div><div><font face="'courier new', monospace"> s = c.createSession(self.username.value, self.password.value)</font></div>
</div><div><font face="'courier new', monospace"> cs = s.getContainerService()</font></div><div><font face="'courier new', monospace"><div> blitzcon = client_wrapper(self.username.value,</div>
<div> self.password.value,</div><div> host=self.host.value, port=4064)</div><div><br></div><div> blitzcon.connect()</div><div> for p in blitzcon.listProjects():</div>
<div> for dataset in p.listChildren():</div><div> if dataset.getName() == self.dataset.value</div><div> <b>dataset_id</b> = dataset.getId()</div><div><br></div></font></div><div>
<div><font face="'courier new', monospace"> imgs = cs.getImages("Dataset", [<b>dataset_id</b>], None)</font></div><div><font face="'courier new', monospace"> d = self.get_dictionary(image_set_list)</font></div>
<div><font face="'courier new', monospace"> for i, img in enumerate(imgs):</font></div><div><font face="'courier new', monospace"> image_set = image_set_list.get_image_set(i)</font></div>
<div><font face="'courier new', monospace"> d[i] = img.getId().getValue()</font></div></div><div><br></div><div>I emboldened dataset_id because you can see that I am establishing a whole second connection just to get it because I was unable to find equivalent methods within omero.gateway which I am using (so far) for everything else.</div>
<div><br></div><div>I was hoping someone could give me a better way of doing this. Additionally I have yet to run into trouble regarding keeping the session alive, but I'm not doing anything special to prevent it from going away so I expect this will be a problem eventually.</div>
<div><br></div><div>Thanks for your help,</div><div>Adam</div></span>