Skip to content

Commit 269b8d6

Browse files
committed
Updated docstrings
1 parent 36b30af commit 269b8d6

2 files changed

Lines changed: 15 additions & 21 deletions

File tree

‎osl_dynamics/meeg/__init__.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
- :py:mod:`~osl_dynamics.meeg.preproc` — Sensor-level preprocessing
1111
(filtering, bad segment/channel detection, QC plots).
1212
- :py:mod:`~osl_dynamics.meeg.rhino` — Surface extraction, coregistration
13-
(RHINO), forward modelling, and template surface scaling (for OPM
14-
data without an MRI).
13+
(RHINO), and forward modelling.
1514
- :py:mod:`~osl_dynamics.meeg.source_recon` — Source reconstruction (LCMV
1615
beamformer).
1716
- :py:mod:`~osl_dynamics.meeg.parcellation` — Parcellation of voxel data

‎osl_dynamics/meeg/rhino.py‎

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def scale_surfaces_to_headshape(
9191
print("Scaling surfaces to headshape")
9292
print("-----------------------------")
9393

94-
# ------------------------------------------
94+
# -------------
9595
# Load surfaces
96-
# ------------------------------------------
96+
# -------------
9797
sfns = SurfaceFilenames(surfaces_dir)
9898

9999
outskin_sform = _get_sform(sfns.bet_outskin_mesh_file)["trans"]
@@ -107,16 +107,16 @@ def scale_surfaces_to_headshape(
107107
scalp_voxels = scalp_voxels[:, indices]
108108
scalp_mm = _xform_points(outskin_sform, scalp_voxels)
109109

110-
# ------------------------------------------
110+
# -------------------------------
111111
# Extract headshape from FIF file
112-
# ------------------------------------------
112+
# -------------------------------
113113
print(f"Loading headshape from {preproc_file}")
114114
headshape_mm, nasion_mm, rpa_mm, lpa_mm = _extract_headshape(preproc_file)
115115
print(f"Found {headshape_mm.shape[1]} headshape points")
116116

117-
# ------------------------------------------
117+
# ---------------------------------
118118
# Initial alignment using fiducials
119-
# ------------------------------------------
119+
# ---------------------------------
120120
print("Computing initial alignment via fiducials")
121121

122122
mni_nasion = np.array([1.0, 85.0, -41.0])
@@ -143,18 +143,18 @@ def scale_surfaces_to_headshape(
143143
)
144144
head2mri_xform, _ = _rigid_transform_3D(mri_fid, polhemus_fid)
145145

146-
# ------------------------------------------
146+
# --------------
147147
# ICP refinement
148-
# ------------------------------------------
148+
# --------------
149149
print(f"Running ICP with {n_init} initialisations")
150150

151151
headshape_mri_mm = _xform_points(head2mri_xform, headshape_mm)
152152
xform_icp, _, _ = _rhino_icp(scalp_mm, headshape_mri_mm, n_init=n_init)
153153
head2mri_refined = xform_icp @ head2mri_xform
154154

155-
# ------------------------------------------
155+
# -----------------------------------------
156156
# Compute affine from point correspondences
157-
# ------------------------------------------
157+
# -----------------------------------------
158158
print("Computing affine transform from surface correspondences")
159159
headshape_aligned = _xform_points(head2mri_refined, headshape_mm)
160160

@@ -176,9 +176,9 @@ def scale_surfaces_to_headshape(
176176
f"y={warp_xform[1,1]:.3f} z={warp_xform[2,2]:.3f}"
177177
)
178178

179-
# ------------------------------------------
179+
# ---------------
180180
# Save scaled MRI
181-
# ------------------------------------------
181+
# ---------------
182182
print("Saving scaled MRI and surfaces")
183183

184184
mri_img = nib.load(sfns.mri_file)
@@ -191,9 +191,9 @@ def scale_surfaces_to_headshape(
191191
smri_img.header.set_sform(scaled_sform, code=sform_code)
192192
nib.save(smri_img, smri_out)
193193

194-
# ------------------------------------------
194+
# --------------------
195195
# Save scaled surfaces
196-
# ------------------------------------------
196+
# --------------------
197197
for mesh_name in ["outskin_mesh", "inskull_mesh", "outskull_mesh"]:
198198
# Scale NIfTI mesh sform
199199
src_nii = os.path.join(surfaces_dir, f"{mesh_name}.nii.gz")
@@ -2844,11 +2844,6 @@ def _binary_majority3d(img):
28442844
).astype(int)
28452845

28462846

2847-
# ---------------------------------------------------------------------------
2848-
# Helpers for scale_surfaces_to_headshape
2849-
# ---------------------------------------------------------------------------
2850-
2851-
28522847
def _extract_headshape(preproc_file):
28532848
"""Extract headshape points and fiducials from a FIF file.
28542849

0 commit comments

Comments
 (0)