File: parcel_intra.py

package info (click to toggle)
nipy 0.1.2%2B20100526-2
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 11,992 kB
  • ctags: 13,434
  • sloc: python: 47,720; ansic: 41,334; makefile: 197
file content (52 lines) | stat: -rw-r--r-- 1,590 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Example of script to parcellate the data from one subject,
using various algorithms.

Note that it can take some time.

author: Bertrand Thirion, 2005-2009
"""
print __doc__

import numpy as np
import os.path as op
import time
import tempfile

#from nipy.io.imageformats import load, save, Nifti1Image 
#import nipy.neurospin.graph as fg
#import nipy.neurospin.graph.field as ff
#from nipy.neurospin.clustering.hierarchical_clustering import \
#     ward_segment, ward_quick_segment
#import nipy.neurospin.spatial_models.parcellation as Pa
from nipy.neurospin.spatial_models.parcel_io import one_subj_parcellation

import get_data_light
get_data_light.getIt()

# ------------------------------------
# 1. Get the data (mask+functional image)
# take several experimental conditions
# time courses could be used instead

nbeta = [29]
data_dir = op.expanduser(op.join('~', '.nipy', 'tests', 'data'))
MaskImage = op.join(data_dir,'mask.nii.gz')
betas = [op.join(data_dir,'spmT_%04d.nii.gz'%n) for n in nbeta]

# set the parameters
nbparcel = 500
mu = 10
nn = 6
write_dir = tempfile.mkdtemp()
verbose = 1


lpa = one_subj_parcellation(MaskImage, betas, nbparcel, nn, 'gkm', 
                            write_dir, mu, verbose)
lpa = one_subj_parcellation(MaskImage, betas, nbparcel, nn, 'ward', 
                            write_dir, mu, verbose)
lpa = one_subj_parcellation(MaskImage, betas, nbparcel, nn, 'ward_and_gkm', 
                            write_dir, mu, verbose)