Skip to content

Avoid writing to file when filtering short streamlines #47

@jhlegarreta

Description

@jhlegarreta

Description

tract_querier offers tools to perform streamline filtering. However, their behavior may offer room for improvement (if I am not missing anything).

If I am not mistaken tract_querier's tract_math tools require their output to be written to disk. I'd dare to say it may be worthwhile exploring the possibility of returning the filtered tractogram instead of writing it to disk.

Expected behavior

Using the tract_remove_short_tracts operation of tract_querier's tract_math tools like:

tract_math.operations['tract_remove_short_tracts'](
                my_unfiltered_tractogram, length_threshold,
                filtered_tractogram_filename)

This seems to require a filename so that the filtered tractogram is written to disk. Then users would be reading it back with

 filtered_tractogram = \
                tract_querier.tractography.tractography_from_file(
                    filtered_tractogram_filename)

I would have expected the tract_math tools to return a tractogram so that a file I/O operation is avoided.

Actual behavior

Using the tract_math tools requires writing/reading the files to/from disk.

Steps to Reproduce

Use any input tractogram and filter streamlines less than a given length using the tract_math. The tract_querier/scripts/tract_querier could be used, modifying it to call

tract_math.operations['tract_remove_short_tracts'](
                my_input_tractogram, length_threshold,
                filtered_tractogram_filename)

Reproducibility

%100

Versions

master

Environment

Ubuntu 16.04 LTS, Python 3.6.5

nibabel==2.5.1
numpy==1.17.3
scipy==1.3.2
six==1.13.0
tract-querier==0.1

Additional Information

Related to #46: to circumvent "single-point streamlines" one could think of using tract_querier's tract_math tract_remove_short_tracts operation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions