Skip to content

Commit

Permalink
cleaning, dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
smeisler committed Sep 4, 2024
1 parent 0307b2f commit bd2bcd3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
38 changes: 36 additions & 2 deletions ingress2qsirecon/utils/interfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
"""

import os
import pandas as pd
import shutil
import tempfile
from textwrap import indent

import itk
import nibabel as nb
import numpy as np
import SimpleITK as sitk
Expand Down Expand Up @@ -609,3 +608,38 @@ def _convert_fsl_to_mrtrix(bval_file, bvec_file, output_fname):
vals = np.loadtxt(bval_file)
gtab = np.column_stack([vecs.T, vals]) * np.array([-1, -1, 1, 1])
np.savetxt(output_fname, gtab, fmt=["%.8f", "%.8f", "%.8f", "%d"])

class _ScansTSVWriterInputSpec(BaseInterfaceInputSpec):
filenames = traits.List(traits.Str, mandatory=True, desc="List of filenames")
source_files = traits.List(traits.Str, mandatory=True, desc="List of source files")
out_file = File("output.tsv", usedefault=True, desc="Output TSV file")

class _ScansTSVWriterOutputSpec(TraitedSpec):
out_file = File(desc="Output TSV file")

class ScansTSVWriter(BaseInterface):
input_spec = _ScansTSVWriterInputSpec
output_spec = _ScansTSVWriterOutputSpec

def _run_interface(self, runtime):
filenames = self.inputs.filenames
source_files = self.inputs.source_files

# Check if lengths match
if len(filenames) != len(source_files):
raise ValueError("filenames and source_files must have the same length")

# Create DataFrame
df = pd.DataFrame({
"filename": filenames,
"source_file": source_files
})

# Write to TSV
df.to_csv(self.inputs.out_file, sep='\t', index=False)
return runtime

def _list_outputs(self):
outputs = self.output_spec().get().copy()
outputs['out_file'] = self.inputs.out_file
return outputs
1 change: 0 additions & 1 deletion ingress2qsirecon/utils/workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""

import os
import shutil
from pathlib import Path

from nipype.pipeline.engine import Workflow
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "Ingress2QSIRecon"
version = "0.1.0"
version = "0.1.1"
description = "Tool to ingress data from other pipelines for use in QSIRecon"
authors = ["Steven Meisler <[email protected]>"]
readme = "README.md"
Expand All @@ -18,9 +18,11 @@ loguru = "^0.7.2"
nibabel = "^5.2.1"
nilearn = "^0.10.4"
nipype = "^1.8.6"
niworkflows = "^1.11.0"
pydantic = "^2.8"
python = "^3.10"
SimpleITK = "^2.4.0"
templateflow = "^24.2.0"

[tool.poetry.urls]
homepage = "https://github.com/PennLINC/ingress2qsirecon"
Expand Down

0 comments on commit bd2bcd3

Please sign in to comment.