nimare.studyset.View
- class View(store, index=None, point_mask=None, context=None)[source]
Bases:
objectA selection of analyses over one immutable store.
Methods
analyses_with_points(point_bool)Analyses with at least one flagged focus, as a view.
Foci for the selection, grouped by analysis.
drop_keys(keys)Narrow to everything except the named analyses.
frame(name)Return a memoised pandas frame.
image_block(imtype, *[, policy])Return the images of one type for the selection.
label_block([annotation])Return the annotation matrix for the selection.
points_in_mask(mask_data, affine)Point-level boolean for foci inside an image mask.
points_near(xyz, radius)Point-level boolean for foci within
radiusmm of any ofxyz.Store analysis row -> position in this selection,
-1where absent.resolve(requirements[, drop_invalid])Intersect each requirement's validity, then resolve against the result.
{full analysis id: position in this selection}, memoised.select(mask_or_positions)Narrow to a subset of the selected analyses.
select_keys(keys, *[, allow_short, strict])Narrow to the named analyses, by full id or short analysis id.
select_points(mask)Narrow to a subset of foci, keeping every analysis.
select_studies(study_keys, *[, exclude, strict])Narrow by parent study.
text_block([field])Return one text field for the selection.
with_context(**changes)Return a view with different execution context.
Properties
storeindexpoint_maskcontextThe full
study-analysisids of the selected analyses.The analysis ids the selected analyses declare, without their study.
Unique study ids of the selected analyses.
- analyses_with_points(point_bool)[source]
Analyses with at least one flagged focus, as a view.
Counted with
bincountover the point-to-analysis column rather thanadd.reduceatover the offsets:reduceatreturns the element at the index when two offsets coincide, so analyses with no foci came back as hits.
- drop_keys(keys)[source]
Narrow to everything except the named analyses.
An id matching nothing is not an error: it is absent from the result either way.
- property keys
The full
study-analysisids of the selected analyses.
- points_in_mask(mask_data, affine)[source]
Point-level boolean for foci inside an image mask.
Uses the coordinates in the context’s space: a Talairach focus and its MNI projection are not the same voxel.
- position_of_row()[source]
Store analysis row -> position in this selection,
-1where absent.Memoised against the view, because every block build wants it.
- resolve(requirements, drop_invalid=True)[source]
Intersect each requirement’s validity, then resolve against the result.
Returns
(narrowed view, {name: block}). Because the narrowing produces a view, every block is aligned to the same analyses by construction – there is no parallel-list bookkeeping to get wrong.
- select_keys(keys, *, allow_short=True, strict=True)[source]
Narrow to the named analyses, by full id or short analysis id.
- Parameters:
keys (
stror array_like ofstr) – Analysis ids, each a full"<study id>-<analysis id>"id or the analysis id on its own.allow_short (
bool, default=True) – Whether an analysis id on its own may be matched.strict (
bool, default=True) – Whether to raise on an id matching no analysis in this selection.
- Raises:
ValueError – If
strictand any id matches nothing. The error names them.
- select_studies(study_keys, *, exclude=False, strict=True)[source]
Narrow by parent study.
strictraises on a study id with no analyses in this selection. It does not apply toexclude, for the reason given ondrop_keys().
- property short_keys
The analysis ids the selected analyses declare, without their study.
- property study_keys
Unique study ids of the selected analyses.