-
Notifications
You must be signed in to change notification settings - Fork 19
Description
We are almost at the point of switching to the new [Data]Class based objects which negates the need to pass around
dataframes of statistics between different steps of the analysis as these are attributes of the dataclass objects (or
can be obtained from the attributes).
This simplifies the process of analysing objects going forward as we don't need to worry about passing these around with
the underlying images to be processed.
However we still want to have dataframes that we can write to .csv at the end.
By using dataclasses we get __dict__() of all attributes for classes for free.
To simplify making the desired dataframes we can leverage this and compile a nested dictionary from the TopoStats
class down to the Molecule class of just the attributes we want.
Perhaps abstracting it out to a recursive function that traverses through an object/dataclass until it gets to something with data to extract at which point it calls __dict__() and takes a subset of the attributes (aka statistics) to return as part of the dictionary.
At the end we can leverage pd.DataFrame.from_dict() to build the resulting statistics dataframe for each image and
molecules within it and then pd.concat() these after all images have been processed to give the desired data to write
to CSV.