Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
34df5fc
allow multiple files in "source" for coregister reslice
chrisgorgo Nov 9, 2010
2447875
support for apply_to_files in coregister write
chrisgorgo Nov 10, 2010
5a2a722
Merge branch 'spm_reslice' of git://github.com/chrisfilo/nipype into …
satra Nov 11, 2010
49c9c19
Added nitime directory in interfaces
Aug 25, 2010
3c88551
Initial skeleton on which the nitime interfaces will sit
Sep 22, 2010
d072c5f
Added a test file
Sep 22, 2010
4476584
More work on the nitime coherence interface
Sep 22, 2010
9f4a0ed
Added a csv file with fmri time-series for nitime interface testing
Sep 29, 2010
a5344d9
Implemented _read_csv, and several changes following testing
Sep 29, 2010
9a37cc8
Some comments and scaffolds in the direction of implementing nitime i…
Sep 29, 2010
e068a91
Changes and enhancements in nitime interface: 1. Data reading not usi…
Oct 26, 2010
fc7caab
Added testing data into the repo.
Oct 29, 2010
e6bcf73
BF Using default trait value and fix to import from nitime.analysis
Oct 29, 2010
16b6db6
Finished first pass of coherence analysis. Outputs now include arrays…
Nov 3, 2010
4d6b47f
Added testing of file-generation.
Nov 3, 2010
d53f356
BF: proper linking/copying multiple files of the same name into worki…
chrisgorgo Nov 10, 2010
20a494b
incremental numbering instead of stacking "c"s
chrisgorgo Nov 11, 2010
75a652b
improved handling of extensions in split_filename
chrisgorgo Nov 11, 2010
ae15b4d
forgot about looping while searching for a new file name
chrisgorgo Nov 12, 2010
8b2b590
fixed filename generation
chrisgorgo Nov 12, 2010
ce26375
Merge branch 'fixes/copyfile' of github.com:chrisfilo/nipype into fix…
chrisgorgo Nov 12, 2010
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
More work on the nitime coherence interface
  • Loading branch information
arokem authored and satra committed Nov 11, 2010
commit 4476584daab32c78cc64f213b64fed0d7ba2f440
64 changes: 62 additions & 2 deletions nipype/interfaces/nitime/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,86 @@

"""

from nipype.utils.misc import package_check

from nipype.interfaces.base import (TraitedSpec, File, InputMultiPath,
OutputMultiPath, Undefined, traits,
BaseInterface)

from nitime.analysis import CoherenceAnalyzer
from nitime import TimeSeries
from nitime.timeseries import TimeSeries

package_check('nitime')
package_check('matplotlib')

class CoherenceAnalyzerInputSpec(TraitedSpec):

#Input either csv file, or time-series object and use _xor_inputs to
#discriminate
_xor_inputs('in_file','in_TS')
in_file = File(desc=('csv file with ROIs on the columns and ',
'time-points on the rows. ROI names at the top row'),
exists=True,
requires=('sampling_rate'))

#If you gave just a file name, you need to specify the sampling_rate:
TR = traits.Float(desc=('The TR used to collect the data',
'in your csv file <in_file>'))

in_TS = traits.Any(desc='a nitime TimeSeries object')

NFFT = traits.Range(low=32,value=64,
desc=('This is the size of the window used for ',
'the spectral estimation. Use values between ',
'32 and the number of samples in your time-series.',
'(Defaults to 64.)'))
n_overlap = traits.Range(low=0,value=0,
desc=('The number of samples which overlap',
'between subsequent windows.(Defaults to 0)'))

frequency_range = traits.ListFloat(value=[0.02, 0.15],
minlen=2,
maxlen=2,
desc=('The range of frequencies over',
'which the analysis will average.',
'[low,high] (Default [0.02,0.15]'))

output_csv_file = traits.File(desc='File to write output')
output_figure_file = traits.File(desc='File to write output figures')
figure_type = traits.Enum('matrix','network',
desc=("The type of plot to generate, where ",
"'matrix' denotes a matrix image and",
"'network' denotes a graph representation"))

class CoherenceAnalyzerOutputSpec(TraitedSpec):
coherence_array = traits.Array(desc=('The pairwise coherence values between',
'the ROIs'))
timedelay_array = traits.Array(desc=('The pairwise time delays between the',
'ROIs (in seconds)'))

coherence_csv = traits.File(desc = ('A csv file containing the pairwise ',
'coherence values'))
timedelay_csv = traits.File(desc = ('A csv file containing the pairwise ',
'time delay values'))

coherence_fig = traits.File(desc = ('Figure representing coherence values'))
timedelay_fig = traits.File(desc = ('Figure representing coherence values'))


class CoherenceAnalyzer(BaseInterface):

# Use the get_attr to pull out the input values from the InputSpec
input_spec = CoherenceAnalyzerInputSpec
output_spec = CoherenceAnayzerOutputSpec

def _read_csv(self):

return roi_labels,TS

#Rewrite _run_interface, but not run
def _run_interface(self,runtime):
lb, ub = self.inputs.frequency_range
if

#Rewrite _list_outputs (look at BET)

def _list_outputs(self):
Expand Down
19 changes: 19 additions & 0 deletions nipype/interfaces/nitime/tests/test_nitime.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
import os
import tempfile
import shutil
from matplotlib import mlab.csv2rec as csv2rec

from nipype.testing import (assert_equal, assert_not_equal, assert_raises,
with_setup, TraitError, parametric, skipif)


def test_read_csv():
"""Test that reading the data from csv file gives you back a reasonable
time-series object """

#XXX need to finish this:
data_rec = csv2rec('data/fmri_timeseries.csv')