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
It's often convenient to have a simple way to group related ABFs (e.g., all recordings from a single cell) within a folder that contains a long series of consecutively-named ABF files.
I often achieve this by taking a picture of a cell and saving it with the same basename as the first ABF for that cell. This "parent" abf indicates the start of a sequence of related ABF files, and the subsequent ABF files are "children".
This may be useful to consider including in the pyabf tools submodule.
Code
importpathlibclassAbfParents:
""" This class helps group ABFs together using filenames. If an ABF file is adjacent to a non-ABF file with the same basename, it indicates that ABF file is a "parent" and subsequent ABFs are grouped together. Typically the non-abf file is a .tif or .jpg photograph of the sample being recorded. """def__init__(self):
self.abfs_by_parent= {}
defadd_folder(self, folder: str):
folder=pathlib.Path(folder)
abfs=folder.glob("*.abf")
others= [x.stemforxinfolder.glob("*.*") ifx.suffix!=".abf"]
last_parent=Noneforabfinabfs:
is_parent=abf.steminothersifis_parent:
self.abfs_by_parent[abf] = []
last_parent=abfself.abfs_by_parent[last_parent].append(abf)
defadd_subfolders(self, folder: str):
folder=pathlib.Path(folder)
sub_folders= [xforxinfolder.glob("*") ifx.is_dir()]
forsub_folderinsub_folders:
self.add_folder(sub_folder)
def__str__(self):
total=sum([len(x) forxinself.abfs_by_parent.values()])
returnf"{total} ABFs ({len(self.abfs_by_parent)} parents)"
It's often convenient to have a simple way to group related ABFs (e.g., all recordings from a single cell) within a folder that contains a long series of consecutively-named ABF files.
I often achieve this by taking a picture of a cell and saving it with the same basename as the first ABF for that cell. This "parent" abf indicates the start of a sequence of related ABF files, and the subsequent ABF files are "children".
This may be useful to consider including in the pyabf tools submodule.
Code
Example
The text was updated successfully, but these errors were encountered: