<html><head><meta charset="utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">Hi Adam,<div><br></div><div>Sorry for the confusion, but the connection you're using for most stuff is the '<span class="Apple-style-span" style="border-collapse: collapse; font-family: 'courier new', monospace; font-size: 13px; ">blitzcon<span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; ">' connection? </span></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'courier new', monospace; font-size: 13px; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; ">Or is 'blitzcon' the "second" connection you're using to get Dataset ID?</span></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'courier new', monospace; font-size: 13px; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; ">Confusingly, we have a 'gateway' service in the createSession() connection, but we also refer to the 'blitzcon' connection as omero.gatewa</span></span></div><div><font class="Apple-style-span" face="Helvetica, monospace"><br></font></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'courier new', monospace; font-size: 13px; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; ">You want to allow the user to browse their Projects and Datasets by name, to get Dataset ID?</span></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; font-family: 'courier new', monospace; font-size: 13px; "><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; ">You can use the container service to list Projects and Datasets...</span></span></div><div><font class="Apple-style-span" face="Helvetica, monospace"><br></font></div><div><div>>>> projects = cs.loadContainerHierarchy("Project", None, None)</div><div>>>> for p in projects:</div><div>>>> print p.getName().getValue()</div><div>>>> for d in p.linkedDatasetList():</div><div>>>> print d.getName().getValue()</div><div><br></div><div>But if you know the name of the Dataset from the start, and you simply want the ID, you CAN use the query service. </div><div>Using the query service is a 'quick and dirty' way of writing your own database queries, but could be more susceptible to changes in the OMERO data model etc. </div><div><br></div><div>Generally you will find it much easier to work with the blitzcon connection.</div><div>You can do </div><div><br></div><div>i = blitzcon.getImage(ID)</div><div>for c in i.listChannels():</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>c.getName()</div><div><br></div><div>However, the blitzcon connection may make more calls to the server and you have less control of this. </div><div>Let us know how you get on,</div><div><br></div><div> Will. </div><div><br></div><div><br></div><div><div>On 4 Feb 2011, at 18:45, Adam Fraser wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><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> _______________________________________________<br>ome-devel mailing list<br><a href="mailto:ome-devel@lists.openmicroscopy.org.uk">ome-devel@lists.openmicroscopy.org.uk</a><br><a href="http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel">http://lists.openmicroscopy.org.uk/mailman/listinfo/ome-devel</a><br></blockquote></div><br><div apple-content-edited="true"> <span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>William Moore</div><div><div>Wellcome Trust Centre for Gene Regulation & Expression</div><div>College of Life Sciences</div><div>MSI/WTB/JBC Complex</div><div>University of Dundee</div><div>Dow Street</div><div>Dundee DD1 5EH</div><div>United Kingdom</div><div><br></div><div>Phone 01382 386364</div></div><div><a href="http://openmicroscopy.org">http://openmicroscopy.org</a></div></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"> </div><br></div></body></html>