nimare.studyset.View

class View(store, index=None, point_mask=None, context=None)[source]

Bases: object

A selection of analyses over one immutable store.

Methods

analyses_with_points(point_bool)

Analyses with at least one flagged focus, as a view.

coordinate_block()

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 radius mm of any of xyz.

position_of_row()

Store analysis row -> position in this selection, -1 where absent.

resolve(requirements[, drop_invalid])

Intersect each requirement's validity, then resolve against the result.

row_of_key()

{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

store

index

point_mask

context

keys

The full study-analysis ids of the selected analyses.

short_keys

The analysis ids the selected analyses declare, without their study.

study_keys

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 bincount over the point-to-analysis column rather than add.reduceat over the offsets: reduceat returns the element at the index when two offsets coincide, so analyses with no foci came back as hits.

coordinate_block()[source]

Foci for the selection, grouped by analysis.

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.

frame(name)[source]

Return a memoised pandas frame. Compatibility surface, not a hot path.

image_block(imtype, *, policy='all')[source]

Return the images of one type for the selection.

property keys

The full study-analysis ids of the selected analyses.

label_block(annotation=None)[source]

Return the annotation matrix for the selection.

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.

points_near(xyz, radius)[source]

Point-level boolean for foci within radius mm of any of xyz.

position_of_row()[source]

Store analysis row -> position in this selection, -1 where 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.

row_of_key()[source]

{full analysis id: position in this selection}, memoised.

select(mask_or_positions)[source]

Narrow to a subset of the selected analyses. O(k).

select_keys(keys, *, allow_short=True, strict=True)[source]

Narrow to the named analyses, by full id or short analysis id.

Parameters:
  • keys (str or array_like of str) – 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 strict and any id matches nothing. The error names them.

select_points(mask)[source]

Narrow to a subset of foci, keeping every analysis.

select_studies(study_keys, *, exclude=False, strict=True)[source]

Narrow by parent study.

strict raises on a study id with no analyses in this selection. It does not apply to exclude, for the reason given on drop_keys().

property short_keys

The analysis ids the selected analyses declare, without their study.

property study_keys

Unique study ids of the selected analyses.

text_block(field='abstract')[source]

Return one text field for the selection.

with_context(**changes)[source]

Return a view with different execution context. No data is touched.