Skip to content

Commit c6384c9

Browse files
committed
DOC: fix docstring for event_design, block_design
Format and extend docstrings. Add mention of default ``_block_`` for block design with no given factors.
1 parent af6cbca commit c6384c9

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

nipy/modalities/fmri/design.py

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def _build_formula_contrasts(spec, fields, order):
122122

123123
def event_design(event_spec, t, order=2, hrfs=(glover,),
124124
level_contrasts=False):
125-
""" Create design matrix from event specification `event_spec`
125+
""" Create design matrix at times `t` for event specification `event_spec`
126126
127127
Create a design matrix for linear model based on an event specification
128128
`event_spec`, evaluating the design rows at a sequence of time values `t`.
@@ -145,19 +145,18 @@ def event_design(event_spec, t, order=2, hrfs=(glover,),
145145
A sequence of (symbolic) HRFs that will be convolved with each event.
146146
Default is ``(glover,)``.
147147
level_contrasts : bool, optional
148-
If True, generate contrasts for each individual level
149-
of each factor.
148+
If True, generate contrasts for each individual level of each factor.
150149
151150
Returns
152151
-------
153152
X : np.ndarray
154153
The design matrix with ``X.shape[0] == t.shape[0]``. The number of
155154
columns will depend on the other fields of `event_spec`.
156155
contrasts : dict
157-
Dictionary of contrasts that is expected to be of interest from the event
158-
specification. Each interaction / effect up to a given order will be
159-
returned. Also, a contrast is generated for each interaction / effect for
160-
each HRF specified in hrfs.
156+
Dictionary of contrasts that is expected to be of interest from the
157+
event specification. Each interaction / effect up to a given order will
158+
be returned. Also, a contrast is generated for each interaction / effect
159+
for each HRF specified in `hrfs`.
161160
"""
162161
fields = list(event_spec.dtype.names)
163162
if 'time' not in fields:
@@ -201,7 +200,7 @@ def block_design(block_spec, t, order=2, hrfs=(glover,),
201200
convolution_dt=0.02,
202201
hrf_interval=(0.,30.),
203202
level_contrasts=False):
204-
""" Create a design matrix from specification of blocks `block_spec`
203+
""" Create design matrix at times `t` for blocks specification `block_spec`
205204
206205
Create design matrix for linear model from a block specification
207206
`block_spec`, evaluating design rows at a sequence of time values `t`.
@@ -211,8 +210,10 @@ def block_design(block_spec, t, order=2, hrfs=(glover,),
211210
----------
212211
block_spec : np.recarray
213212
A recarray having at least a field named 'start' and a field named 'end'
214-
signifying the block time, and all other fields will be treated as
215-
factors in an ANOVA-type model.
213+
signifying the block onset and offset times. All other fields will be
214+
treated as factors in an ANOVA-type model. If there is no field other
215+
than 'start' and 'end', add a single-level placeholder block type
216+
``_block_``.
216217
t : np.ndarray
217218
An array of np.float values at which to evaluate the design. Common
218219
examples would be the acquisition times of an fMRI image.
@@ -239,13 +240,13 @@ def block_design(block_spec, t, order=2, hrfs=(glover,),
239240
Returns
240241
-------
241242
X : np.ndarray
242-
The design matrix with X.shape[0] == t.shape[0]. The number of
243-
columns will depend on the other fields of block_spec.
243+
The design matrix with ``X.shape[0] == t.shape[0]``. The number of
244+
columns will depend on the other fields of `block_spec`.
244245
contrasts : dict
245-
Dictionary of contrasts that is expected to be of interest from
246-
the block specification. For each interaction / effect up to a
247-
given order will be returned. Also, a contrast is generated for
248-
each interaction / effect for each HRF specified in hrfs.
246+
Dictionary of contrasts that are expected to be of interest from the
247+
block specification. Each interaction / effect up to a given order will
248+
be returned. Also, a contrast is generated for each interaction / effect
249+
for each HRF specified in `hrfs`.
249250
"""
250251
fields = list(block_spec.dtype.names)
251252
if 'start' not in fields or 'end' not in fields:

0 commit comments

Comments
 (0)