Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion AFQ/api/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,14 @@ def export_up_to(self, attr_name="help"):
for inputs in calcdata.calcs[idx].inputs:
self.export(inputs)

def export_all(self, viz=True, afqbrowser=True, xforms=True, indiv=True):
def export_all(
self,
viz=True,
afqbrowser=True,
xforms=True,
indiv=True,
delete_full_tractogram=False,
):
"""Exports all the possible outputs

Parameters
Expand All @@ -714,6 +721,14 @@ def export_all(self, viz=True, afqbrowser=True, xforms=True, indiv=True):
the AFQ segmentation algorithm, individual ROIs are also
output.
Default: True
delete_full_tractogram : bool
Whether to delete the full, unsegmented tractogram (and its
associated json) after all other outputs have been generated.
This can be useful for saving disk space, as the full
tractogram is typically over 90 percent of the total output size.
Only the full tractogram and its json are deleted; all other
outputs are left in place.
Default: False
"""
start_time = time()

Expand All @@ -722,8 +737,19 @@ def export_all(self, viz=True, afqbrowser=True, xforms=True, indiv=True):
self.combine_profiles()
if afqbrowser:
self.assemble_AFQ_browser()
if delete_full_tractogram:
self.delete_full_tractogram()
Comment thread
36000 marked this conversation as resolved.
self.logger.info(f"Time taken for export all: {str(time() - start_time)}")

def delete_full_tractogram(self):
"""
Delete the full, unsegmented tractogram (and its associated json)
for every subject and session. Only the full tractogram and its
json are deleted; all other outputs are left in place.
"""
for pAFQ in self.pAFQ_list:
pAFQ.delete_full_tractogram()

def cmd_outputs(
self, cmd="rm", dependent_on=None, up_to=None, exceptions=None, suffix=""
):
Expand Down
29 changes: 27 additions & 2 deletions AFQ/api/participant.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
import math
import os
import os.path as op
import tempfile
from math import radians
Expand Down Expand Up @@ -30,7 +31,7 @@
from AFQ.tasks.utils import get_base_fname
from AFQ.tasks.viz import get_viz_plan
from AFQ.utils.bin import pyafq_str_to_val
from AFQ.utils.path import apply_cmd_to_afq_derivs
from AFQ.utils.path import apply_cmd_to_afq_derivs, drop_extension
from AFQ.viz.utils import BEST_BUNDLE_ORIENTATIONS, get_eye, trim

__all__ = ["ParticipantAFQ"]
Expand Down Expand Up @@ -240,7 +241,9 @@ def export_up_to(self, attr_name="help"):
for inputs in calcdata.calcs[idx].inputs:
self.export(inputs)

def export_all(self, viz=True, xforms=True, indiv=True):
def export_all(
self, viz=True, xforms=True, indiv=True, delete_full_tractogram=False
):
f""" Exports all the possible outputs
{valid_exports_string}

Expand All @@ -262,11 +265,33 @@ def export_all(self, viz=True, xforms=True, indiv=True):
the AFQ segmentation algorithm, individual ROIs are also
output.
Default: True
delete_full_tractogram : bool
Whether to delete the full, unsegmented tractogram (and its
associated json) after all other outputs have been generated.
This can be useful for saving disk space, as the full
tractogram is typically over 90 percent of the total output size.
Only the full tractogram and its json are deleted;
all other outputs are left in place.
Default: False
"""
start_time = time()
export_all_helper(self, xforms, indiv, viz)
if delete_full_tractogram:
self.delete_full_tractogram()
self.logger.info(f"Time taken for export all: {time() - start_time}")

def delete_full_tractogram(self):
"""
Delete the full, unsegmented tractogram (and its associated json).
Only the full tractogram and its json are deleted; all other
outputs are left in place.
"""
tractogram_file = self.export("streamlines")
for fname in (tractogram_file, drop_extension(tractogram_file) + ".json"):
if op.exists(fname):
os.remove(fname)
self.logger.info(f"Deleted {fname}")

def participant_montage(self, images_per_row=3, anatomy=True, bundle_names=None):
"""
Generate montage of all bundles for a given subject.
Expand Down
3 changes: 3 additions & 0 deletions AFQ/data/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2307,6 +2307,9 @@ def fetch_hcp(
data_files[
op.join(sess_dir, "anat", f"sub-{subject}_aparc+aseg_seg.nii.gz")
] = f"{study}/{subject}/T1w/aparc+aseg.nii.gz"
data_files[
op.join(sess_dir, "anat", f"sub-{subject}_desc-PVE_probseg.nii.gz")
] = f"{study}/{subject}/T1w/wmparc.nii.gz"

download_files = {}
for k in data_files.keys():
Expand Down
Loading