You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In light of changing what [AFMReader returns](AFM-SPM/AFMReader#112** so that _just** the data is
returned we will need to update TopoStats to handle this.
IMPORTANT This will require co-ordination with AFMReader releases with clear advice to update to newer versions of
AFMReader and pip install --no-cache-dir --upgrade topostats.
We then have a section that was introduced to handle whether we wanted different components starting on Line
683
try:
# We want everything if performing any step beyond filtering (or explicitly ask for None/"all")ifextractin [None, "all", "grains", "grainstats"]:
return (image, px_to_nm_scaling, data)
# Otherwise we want the raw/image_originalifextract=="filter":
return (image, px_to_nm_scaling, None)
return (data[map_stage_to_image[extract]], px_to_nm_scaling, None)
exceptKeyErroraske:
raiseKeyError(f"Can not extract array of type '{extract}' from .topostats objects.") fromke
...as we will only ever be returning data this can be replaced with
returndata
LoadScans.get_data()
There are a logical checks here that may need changing to account for only receiving data. This section extracts self.imageselt.pixel_to_nm_scaling and optionally data depending on the type of processing being undertaken. This
is stored in the self.extract and represents all or the stage (e.g. filter, grain, grainstats).
A key point which I missed when working on this was that the else: after the try: ... except: ... as I forgot that
the else: will run if no exception is raised (i.e. try: is successful), and this step builds a dictionary of the
images/data.
try:
ifsuffix==".topostats"andself.extractin (None, "all", "grains", "grainstats"):
self.image, self.pixel_to_nm_scaling, data=self.load_topostats()
elifsuffix==".topostats"andself.extractnotin (None, "all"):
self.image, self.pixel_to_nm_scaling, _=self.load_topostats(self.extract)
else:
self.image, self.pixel_to_nm_scaling=suffix_to_loader[suffix]()
exceptExceptionase:
if"Channel"instr(e) and"not found"instr(e):
LOGGER.warning(e) # log the specific error messageLOGGER.warning(f"[{self.filename}] Channel {self.channel} not found, skipping image.")
else:
raiseelse:
ifsuffix==".asd":
forindex, frameinenumerate(self.image):
self._check_image_size_and_add_to_dict(image=frame, filename=f"{self.filename}_{index}")
# If we have extracted the image dictionary (only possible with .topostats files) we add that to the# dictionaryelifdataisnotNone:
data["img_path"] =img_path.with_suffix("")
self.img_dict[self.filename] =self.clean_dict(img_dict=data)
# Otherwise check the size and add image to dictionaryelse:
self._check_image_size_and_add_to_dict(image=self.image, filename=self.filename)
Could probably be
try:
ifsuffix==".topostats":
data=self.load_topostats()
self.image=data["image"]
self.pixel_to_nm_scaling=data["pixel_to_nm_scaling"]
else:
self.image, self.pixel_to_nm_scaling=suffix_to_loader[suffix]()
exceptExceptionase:
if"Channel"instr(e) and"not found"instr(e):
LOGGER.warning(e) # log the specific error messageLOGGER.warning(f"[{self.filename}] Channel {self.channel} not found, skipping image.")
else:
raiseelse:
ifsuffix==".asd":
forindex, frameinenumerate(self.image):
self._check_image_size_and_add_to_dict(image=frame, filename=f"{self.filename}_{index}")
# If we have extracted the image dictionary (only possible with .topostats files) we add that to the# dictionaryelifdataisnotNone:
data["img_path"] =img_path.with_suffix("")
self.img_dict[self.filename] =self.clean_dict(img_dict=data)
# Otherwise check the size and add image to dictionaryelse:
self._check_image_size_and_add_to_dict(image=self.image, filename=self.filename)
run_modules.py
The entry points/functions for running topostats {filters|grains} shouldn't need changing I don't think but worth
noting this is where the returned data is used. Something in the back of my mind says they will need changing but I
can't see it right now, perhaps it will be the process_filters() as this will have to extract the original_image from
the returned data as it will no longer be receiving a dictionary with this as the first item. Probably similar for the process() function too, but I think the process_grains() function will be ok as its expecting to get a dictionary.
The text was updated successfully, but these errors were encountered:
In light of changing what [AFMReader returns](AFM-SPM/AFMReader#112** so that _just** the data is
returned we will need to update TopoStats to handle this.
IMPORTANT This will require co-ordination with AFMReader releases with clear advice to update to newer versions of
AFMReader and
pip install --no-cache-dir --upgrade topostats
.Points that need changing....
io.py
LoadScans.load_topostats()
Line 679
...will be...
We then have a section that was introduced to handle whether we wanted different components starting on Line
683
...as we will only ever be returning
data
this can be replaced withLoadScans.get_data()
There are a logical checks here that may need changing to account for only receiving
data
. This section extractsself.image
selt.pixel_to_nm_scaling
and optionallydata
depending on the type of processing being undertaken. Thisis stored in the
self.extract
and representsall
or the stage (e.g.filter
,grain
,grainstats
).A key point which I missed when working on this was that the
else:
after thetry: ... except: ...
as I forgot thatthe
else:
will run if no exception is raised (i.e.try:
is successful), and this step builds a dictionary of theimages/data.
Line 782
Could probably be
run_modules.py
The entry points/functions for running
topostats {filters|grains}
shouldn't need changing I don't think but worthnoting this is where the returned data is used. Something in the back of my mind says they will need changing but I
can't see it right now, perhaps it will be the
process_filters()
as this will have to extract theoriginal_image
fromthe returned
data
as it will no longer be receiving a dictionary with this as the first item. Probably similar for theprocess()
function too, but I think theprocess_grains()
function will be ok as its expecting to get a dictionary.The text was updated successfully, but these errors were encountered: