laion_fmri.templates¶
Template-space projection of subject-T1w data.
Wraps two chains so callers reach a supported template through
to_template(..., target=...) without touching the external
libraries:
Surface chain: T1w volume → fsnative surface (
nilearn.surface.vol_to_surf) → fsaverage surface (nitransforms.surface.SurfaceResampler). Used for thefsaveragetarget.Volume chain: T1w volume → MNI305 via
nitransforms.linear.Affinereading the recon’stalairach.lta. Used for theMNI305target.
Functions
|
Resample fsnative-surface input onto a surface template. |
|
Project subject-T1w-space values into a template space. |
|
Volume-input → surface-target shortcut around |
|
Volume-input → volume-target shortcut around |
- laion_fmri.templates.surface_to_template(subject, values, target='fsaverage', *, hemi=None, fsaverage_density='fsaverage5', output_dir=None, desc=None, session=None)[source]¶
Resample fsnative-surface input onto a surface template.
- Parameters:
subject (Subject)
values (ndarray | dict[str, ndarray]) – Per-hemi fsnative-vertex array, or a
{"L": ..., "R": ...}dict. With a single array,hemimust specify which hemisphere the array belongs to.target (str) – Surface target (currently only
"fsaverage").hemi ("L" | "R" | None) – Required when
valuesis a single array. Ignored whenvaluesis a dict.fsaverage_density (str) –
"fsaverage5","fsaverage6","fsaverage7"/"fsaverage".output_dir – BIDS-writer kwargs; see
to_template().desc – BIDS-writer kwargs; see
to_template().session – BIDS-writer kwargs; see
to_template().
- Returns:
Same container type as
values.- Return type:
- laion_fmri.templates.to_template(subject, values, target, *, hemi=None, route='auto', surface='white', fsaverage_density='fsaverage5', fslr_density='32k', interpolation='linear', output_dir=None, desc=None, session=None, mask_source='anatomical')[source]¶
Project subject-T1w-space values into a template space.
- Parameters:
subject (Subject)
values (np.ndarray | str | Path) – 1-D over the brain mask, 2-D
(n_trials, n_voxels), or a path to a NIfTI already on the subject’s T1w grid.target (str) – One of the entries in
laion_fmri.templates._SUPPORTED_TARGETS.hemi ("L" | "R" | None) – Hemisphere selector for surface targets.
route ("auto" | "surface" | "volume") – Currently every supported target has a single route, so
"auto"always resolves to that route. The keyword is retained for forward compatibility; passing the wrong route for a target (e.g.route="surface"for"MNI305") raisesValueError.surface (str) – Surface used by the vol→surf sampling step (
"white","pial", or"midthickness").fsaverage_density (str) –
"fsaverage5"(10k/hemi),"fsaverage6"(41k), or"fsaverage7"(164k).fslr_density (str) –
"32k"or"164k".interpolation (str) – Forwarded to
nilearn.surface.vol_to_surf.output_dir (Path | None) – If given, also writes BIDS-conformant files to disk.
desc (str | None) – BIDS
desc-andses-tokens for the output filename(s).session (str | None) – BIDS
desc-andses-tokens for the output filename(s).mask_source (
"anatomical"(default) |"rsquare") – Which brain mask the inputvalueswas produced under; seeSubject.get_brain_mask(). Must match the mask source used in the upstreamget_betas/get_noise_ceilingcall.
- Returns:
For surface targets (1-D ndarray, 2-D if input was)
multi-trial, or a
{"L": ..., "R": ...}dict whenhemi=None.For volume targets (
nibabel.Nifti1Image.)
- laion_fmri.templates.volume_to_surface(subject, values, target='fsaverage', **kwargs)[source]¶
Volume-input → surface-target shortcut around
to_template().Refuses volume targets so the caller’s intent is checked at the call site instead of silently routing somewhere unexpected.
- laion_fmri.templates.volume_to_template(subject, values, target, **kwargs)[source]¶
Volume-input → volume-target shortcut around
to_template().