@@ -155,7 +155,7 @@ def set_external_info(
155155 img : ImageI ,
156156 well : str ,
157157 idx : int ,
158- lsid : str ,
158+ overwrite_path : str ,
159159 entityType : str ,
160160 entityId : int
161161) -> ImageI :
@@ -167,8 +167,8 @@ def set_external_info(
167167 img (ImageI): OMERO image
168168 well (str | None): Optional well position (e.g. 'A1')
169169 idx (int | None): Optional well sample / field index
170- lsid (str | None): Optional custom LSID path. If None, path is
171- derived from image's clientpath
170+ overwrite_path (str | None): Optional custom path. If None, path is
171+ derived from image's clientpath.
172172 entityType (str | None): Optional entity type. Defaults to
173173 'com.glencoesoftware.ngff:multiscales'
174174 entityId (int | None): Optional entity ID. Defaults to 3
@@ -184,30 +184,36 @@ def set_external_info(
184184 entityType = "com.glencoesoftware.ngff:multiscales"
185185 if not entityId :
186186 entityId = 3
187- if lsid :
188- path = lsid
187+
188+ img_path = _get_path (conn , img .id )
189+ if overwrite_path :
190+ if not overwrite_path .endswith ("/" ):
191+ path = f"{ overwrite_path } /"
192+ else :
193+ path = overwrite_path
189194 else :
190- path = _get_path (conn , img .id )
191- if METADATA_XML_RE .match (path ):
192- metadata_xml = METADATA_XML_RE .match (path ).group (1 )
193- if well :
194- match = WELL_POS_RE .match (well )
195- if match :
196- col = match .group ("col" )
197- row = match .group ("row" )
198- path = path .replace (metadata_xml , f"{ row } " )
199- path = f"/{ path } /{ col } /{ idx } "
200- else :
201- raise ValueError (f"Couldn't parse well position: { well } " )
202- else :
203- series = img .getSeries ()._val
204- path = path .replace (metadata_xml , f"{ series } " )
205- path = f"/{ path } "
195+ if METADATA_XML_RE .match (img_path ):
196+ metadata_xml = METADATA_XML_RE .match (img_path ).group (1 )
197+ path = img_path .replace (metadata_xml ,"" )
198+ path = f"/{ path } "
206199 else :
207200 raise ValueError (
208- f"Doesn't seem to be an ome.zarr: { path } "
201+ f"Doesn't seem to be an ome.zarr: { img_path } "
209202 )
210203
204+ if well :
205+ match = WELL_POS_RE .match (well )
206+ if match :
207+ col = match .group ("col" )
208+ row = match .group ("row" )
209+ path = f"{ path } { row } /{ col } /{ idx } "
210+ else :
211+ raise ValueError (f"Couldn't parse well position: { well } " )
212+ else :
213+ series = img .getSeries ()._val
214+ path = f"{ path } { series } "
215+
216+
211217 info = ExternalInfoI ()
212218 info .entityType = rstring (entityType )
213219 info .entityId = rlong (entityId )
0 commit comments