[med-svn] [python-mne] 25/376: more on doc
Yaroslav Halchenko
debian at onerussian.com
Fri Nov 27 17:21:59 UTC 2015
This is an automated email from the git hooks/post-receive script.
yoh pushed a commit to annotated tag v0.1
in repository python-mne.
commit 3c98f6ec105c34bef231118edc00c5bd156fcb42
Author: Alexandre Gramfort <alexandre.gramfort at inria.fr>
Date: Thu Dec 30 18:00:23 2010 -0500
more on doc
---
examples/read_stc.py | 23 ++++++++++-------------
fiff/channels.py | 14 ++++----------
fiff/cov.py | 52 +++++++++++++++++++++++++++++-----------------------
fiff/ctf.py | 6 +++---
fiff/event.py | 15 +++++++++------
fiff/evoked.py | 35 +++++++++++++++++++++++------------
fiff/forward.py | 16 ++++++++--------
fiff/inverse.py | 10 +++++-----
fiff/matrix.py | 14 ++++++--------
fiff/meas_info.py | 4 ++--
10 files changed, 99 insertions(+), 90 deletions(-)
diff --git a/examples/read_stc.py b/examples/read_stc.py
index 96bd266..e3fd2ed 100644
--- a/examples/read_stc.py
+++ b/examples/read_stc.py
@@ -1,4 +1,7 @@
-"""Reading a raw file segment
+"""Reading an STC file
+
+STC files contain activations on cortex ie. source
+reconstructions
"""
print __doc__
@@ -7,16 +10,10 @@ import fiff
fname = 'MNE-sample-data/MEG/sample/sample_audvis-ave-7-meg-lh.stc'
stc = fiff.read_stc(fname)
-fiff.write_stc("tmp.stc", stc)
-stc2 = fiff.read_stc("tmp.stc")
-
-from scipy import linalg
-print linalg.norm(stc['data'] - stc2['data'])
-# n_vertices, n_samples = stc['data'].shape
-# print "tmin : %s (s)" % stc['tmin']
-# print "tstep : %s" % stc['tstep']
-# print "tmax : %s (s)" % (stc['tmin'] + stc['tstep'] * n_samples)
-# print "stc data size: %s (nb of vertices) x %s (nb of samples)" % (
-# n_vertices, n_samples)
-#
+n_vertices, n_samples = stc['data'].shape
+print "tmin : %s (s)" % stc['tmin']
+print "tstep : %s" % stc['tstep']
+print "tmax : %s (s)" % (stc['tmin'] + stc['tstep'] * n_samples)
+print "stc data size: %s (nb of vertices) x %s (nb of samples)" % (
+ n_vertices, n_samples)
diff --git a/fiff/channels.py b/fiff/channels.py
index dae6504..01ec9ba 100644
--- a/fiff/channels.py
+++ b/fiff/channels.py
@@ -3,16 +3,10 @@ from .tag import find_tag
from .constants import FIFF
-def read_bad_channels(fid, node):
- """
- %
- % [bads] = fiff_read_bad_channels(fid,node)
- %
- % Reas the bad channel list from a node if it exists
- %
- % fid - The file id
- % node - The node of interest
- %
+def _read_bad_channels(fid, node):
+ """Read bad channels
+
+ It returns the list of channel's names.
"""
nodes = dir_tree_find(node, FIFF.FIFFB_MNE_BAD_CHANNELS)
diff --git a/fiff/cov.py b/fiff/cov.py
index 237b9c3..2d4529d 100644
--- a/fiff/cov.py
+++ b/fiff/cov.py
@@ -5,22 +5,28 @@ from .constants import FIFF
from .tag import find_tag
from .tree import dir_tree_find
from .proj import read_proj
-from .channels import read_bad_channels
+from .channels import _read_bad_channels
def read_cov(fid, node, cov_kind):
- """
- %
- % [cov] = mne_read_cov(fid, node, kind)
- %
- % Reads a covariance matrix from a fiff file
- %
- % fid - an open file descriptor
- % node - look for the matrix in here
- % cov_kind - what kind of a covariance matrix do we want?
- %
- """
+ """Read a noise covariance matrix
+
+ Parameters
+ ----------
+ fid: file
+ The file descriptor
+
+ node: dict
+ The node in the FIF tree
+
+ cov_kind: int
+ The type of covariance. XXX : clarify
+ Returns
+ -------
+ data: dict
+ The noise covariance
+ """
# Find all covariance matrices
covs = dir_tree_find(node, FIFF.FIFFB_MNE_COV)
if len(covs) == 0:
@@ -99,7 +105,7 @@ def read_cov(fid, node, cov_kind):
projs = read_proj(fid, this)
# Read the bad channel list
- bads = read_bad_channels(fid, this)
+ bads = _read_bad_channels(fid, this)
# Put it together
cov = dict(kind=cov_kind, diag=diagmat, dim=dim, names=names,
@@ -120,6 +126,7 @@ from .proj import write_proj
def write_cov(fid, cov):
+
"""
%
%
@@ -178,16 +185,15 @@ def write_cov(fid, cov):
def write_cov_file(fname, cov):
- """
- %
- % function mne_write_cov_file(name,cov)
- %
- % Write a complete fif file containing a covariance matrix
- %
- % fname filename
- % cov the covariance matrix to write
- %
- %
+ """Write a noise covariance matrix
+
+ Parameters
+ ----------
+ fname: string
+ The name of the file
+
+ cov: dict
+ The noise covariance
"""
fid = start_file(fname)
diff --git a/fiff/ctf.py b/fiff/ctf.py
index f5c7461..6fa9a96 100644
--- a/fiff/ctf.py
+++ b/fiff/ctf.py
@@ -9,10 +9,10 @@ def hex2dec(s):
return int(s, 16)
-def read_named_matrix(fid, node, matkind):
+def _read_named_matrix(fid, node, matkind):
"""
%
- % [mat] = fiff_read_named_matrix(fid,node)
+ % [mat] = fiff__read_named_matrix(fid,node)
%
% Read named matrix from the given node
%
@@ -96,7 +96,7 @@ def read_ctf_comp(fid, node, chs):
for node in comps:
# Read the data we need
- mat = read_named_matrix(fid, node, FIFF.FIFF_MNE_CTF_COMP_DATA)
+ mat = _read_named_matrix(fid, node, FIFF.FIFF_MNE_CTF_COMP_DATA)
for p in range(node.nent):
kind = node.dir[p].kind
pos = node.dir[p].pos
diff --git a/fiff/event.py b/fiff/event.py
index fcac9a6..a4d6672 100644
--- a/fiff/event.py
+++ b/fiff/event.py
@@ -53,12 +53,15 @@ def read_events(filename):
def write_events(filename, event_list):
- """
- %
- % mne_write_events(filename,eventlist)
- %
- % Write an event list into a fif file
- %
+ """Write events to file
+
+ Parameters
+ ----------
+ filename: string
+ name of the fif file
+
+ events: array, shape (n_events, 3)
+ The list of events
"""
# Start writing...
fid = start_file(filename)
diff --git a/fiff/evoked.py b/fiff/evoked.py
index 013c481..5038f2d 100644
--- a/fiff/evoked.py
+++ b/fiff/evoked.py
@@ -8,13 +8,23 @@ from .meas_info import read_meas_info
def read_evoked(fname, setno=0):
- """
- [data] = fiff_read_evoked(fname,setno)
+ """Read an evoked dataset
- Read one evoked data set
+ Parameters
+ ----------
+ fname: string
+ The file name.
- """
+ setno: int
+ The index of the evoked dataset to read. FIF
+ file can contain multiple datasets.
+ Returns
+ -------
+ data: dict
+ The evoked dataset
+
+ """
if setno < 0:
raise ValueError, 'Data set selector must be positive'
@@ -220,14 +230,15 @@ from .ctf import write_ctf_comp
def write_evoked(name, data):
- """
- %
- % function fiff_write_evoked(name,data)
- %
- % name filename
- % data the data structure returned from fiff_read_evoked
- %
- %
+ """Write an evoked dataset to a file
+
+ Parameters
+ ----------
+ name: string
+ The file name.
+
+ data: dict
+ The evoked dataset obtained with read_evoked
"""
# Create the file and save the essentials
diff --git a/fiff/forward.py b/fiff/forward.py
index 456fdf5..87a014c 100644
--- a/fiff/forward.py
+++ b/fiff/forward.py
@@ -5,10 +5,10 @@ from scipy import linalg
from .constants import FIFF
from .open import fiff_open
from .tree import dir_tree_find
-from .channels import read_bad_channels
+from .channels import _read_bad_channels
from .tag import find_tag
from .source_space import read_source_spaces, find_source_space_hemi
-from .matrix import read_named_matrix, transpose_named_matrix
+from .matrix import _read_named_matrix, _transpose_named_matrix
def _block_diag(A, n):
@@ -152,17 +152,17 @@ def _read_one(fid, node):
one['nchan'] = tag.data
try:
- one['sol'] = read_named_matrix(fid, node,
+ one['sol'] = _read_named_matrix(fid, node,
FIFF.FIFF_MNE_FORWARD_SOLUTION)
- one['sol'] = transpose_named_matrix(one['sol'])
+ one['sol'] = _transpose_named_matrix(one['sol'])
except Exception as inst:
fid.close()
raise 'Forward solution data not found (%s)' % inst
try:
- one['sol_grad'] = read_named_matrix(fid, node,
+ one['sol_grad'] = _read_named_matrix(fid, node,
FIFF.FIFF_MNE_FORWARD_SOLUTION_GRAD)
- one['sol_grad'] = transpose_named_matrix(one['sol_grad'])
+ one['sol_grad'] = _transpose_named_matrix(one['sol_grad'])
except Exception as inst:
one['sol_grad'] = None
@@ -206,7 +206,7 @@ def read_forward_solution(fname, force_fixed=False, surf_ori=False,
Returns
-------
- fwt: dict
+ fwd: dict
The forward solution
"""
@@ -240,7 +240,7 @@ def read_forward_solution(fname, force_fixed=False, surf_ori=False,
fwd = None
# Bad channel list
- bads = read_bad_channels(fid, tree)
+ bads = _read_bad_channels(fid, tree)
print '\t%d bad channels read' % len(bads)
diff --git a/fiff/inverse.py b/fiff/inverse.py
index 6ce1fac..7ed16e6 100644
--- a/fiff/inverse.py
+++ b/fiff/inverse.py
@@ -1,7 +1,7 @@
from .constants import FIFF
from .open import fiff_open
from .tag import find_tag
-from .matrix import read_named_matrix, transpose_named_matrix
+from .matrix import _read_named_matrix, _transpose_named_matrix
from .cov import read_cov
from .proj import read_proj
from .tree import dir_tree_find
@@ -103,19 +103,19 @@ def read_inverse_operator(fname):
#
inv['eigen_leads_weighted'] = False
try:
- inv['eigen_leads'] = read_named_matrix(fid, invs, FIFF.FIFF_MNE_INVERSE_LEADS)
+ inv['eigen_leads'] = _read_named_matrix(fid, invs, FIFF.FIFF_MNE_INVERSE_LEADS)
except:
inv['eigen_leads_weighted'] = True
try:
- inv.eigen_leads = read_named_matrix(fid,invs,FIFF.FIFF_MNE_INVERSE_LEADS_WEIGHTED);
+ inv.eigen_leads = _read_named_matrix(fid,invs,FIFF.FIFF_MNE_INVERSE_LEADS_WEIGHTED);
except Exception as inst:
raise ValueError, '%s' % inst
#
# Having the eigenleads as columns is better for the inverse calculations
#
- inv['eigen_leads'] = transpose_named_matrix(inv['eigen_leads'])
+ inv['eigen_leads'] = _transpose_named_matrix(inv['eigen_leads'])
try:
- inv['eigen_fields'] = read_named_matrix(fid, invs, FIFF.FIFF_MNE_INVERSE_FIELDS)
+ inv['eigen_fields'] = _read_named_matrix(fid, invs, FIFF.FIFF_MNE_INVERSE_FIELDS)
except Exception as inst:
raise ValueError, '%s' % inst
diff --git a/fiff/matrix.py b/fiff/matrix.py
index ce51a4c..3eb82d0 100644
--- a/fiff/matrix.py
+++ b/fiff/matrix.py
@@ -2,7 +2,7 @@ from .constants import FIFF
from .tag import find_tag, has_tag
-def transpose_named_matrix(mat):
+def _transpose_named_matrix(mat):
"""Transpose mat inplace (no copy)
"""
mat['nrow'] = mat['ncol']
@@ -13,13 +13,11 @@ def transpose_named_matrix(mat):
return mat
-def read_named_matrix(fid, node, matkind):
- """
- %
- % [mat] = fiff_read_named_matrix(fid,node)
- %
- % Read named matrix from the given node
- %
+def _read_named_matrix(fid, node, matkind):
+ """Read named matrix from the given node
+
+ XXX
+
"""
# Descend one level if necessary
diff --git a/fiff/meas_info.py b/fiff/meas_info.py
index 9858fed..1e7d6e8 100644
--- a/fiff/meas_info.py
+++ b/fiff/meas_info.py
@@ -6,7 +6,7 @@ from .constants import FIFF
from .tag import read_tag
from .proj import read_proj
from .ctf import read_ctf_comp
-from .channels import read_bad_channels
+from .channels import _read_bad_channels
def read_meas_info(source, tree=None):
@@ -187,7 +187,7 @@ def read_meas_info(source, tree=None):
comps = read_ctf_comp(fid, meas_info, chs)
# Load the bad channel list
- bads = read_bad_channels(fid, meas_info)
+ bads = _read_bad_channels(fid, meas_info)
#
# Put the data together
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-mne.git
More information about the debian-med-commit
mailing list