Skip to content

General Question: How to use simple merge to merge skel_ids spread across different folders? #92

@Mohinta2892

Description

@Mohinta2892

Hello!

I have written a tiny snippet as below to merge skels of the same label id that are spread across many folders. However, after merge when I visualise it, no skeleton gets plotted. The final file contains data as attached.

I wanted to know what I am doing incorrectly and get your feedback if this is how simple_merge is to be used?

output_skels = “/path/to/out_skels"
## read skel files for the same label id
skels_to_merge = [('27049069.swc',
                   ‘/path1/27049069.swc|/path2/27049069.swc|/path3/27049069.swc|/path4/27049069.swc')]

for i, files in enumerate(skels_to_merge):
    filename = files[0]
    filepaths = files[1].split('|')
    basename, ext = os.path.splitext(filename)
    skels_list = []
    for fp in filepaths:
        if ext == ".swc":
            with open(fp, "rt") as swc:
                skel = Skeleton.from_swc(swc.read())
                skels_list.append(skel)
                # skel.viewer()

    skel = Skeleton.simple_merge(skels_list).consolidate()
    skel = kimimaro.postprocess(
        skel,
        dust_threshold=1000,  # physical units
        tick_threshold=3500  # physical units
    )
    # print(skel)
    fname = f"{output_skels}/{filename}"
    with open(fname, "wt") as f:
        f.write(skel.to_swc())

27049069.swc.zip

Thank you,
Samia

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions