Repository: mne-tools/mne-python

Issue:
Brain and source space are not aligned in the left_cerebellum_volume_source example
### Description of the problem

In the [left_cerebellum_volume_source example](https://mne.tools/stable/auto_examples/forward/left_cerebellum_volume_source.html), the final display using the following freeview command:
```
nii_fname = 'mne_sample_lh-cerebellum-cortex.nii'
src.export_volume(nii_fname, mri_resolution=True)


from mne.utils import run_subprocess
mri_fname = subjects_dir + '/sample/mri/brain.mgz'
run_subprocess(['freeview', '-v', mri_fname, '-v',
                    '%s:colormap=lut:opacity=0.5' % aseg_fname, '-v',
                    '%s:colormap=jet:colorscale=0,2' % nii_fname,
                    '-slice', '157 75 105'])
```
shows non aligned brain/source space:

![image](https://github.com/mne-tools/mne-python/assets/28844486/88cd0379-68a7-4f1d-bd05-5ec76c544297)


When checking the sources `coord_frame`:
```
[s['coord_frame'] for s in src]
[5 (FIFFV_COORD_MRI), 5 (FIFFV_COORD_MRI), 5 (FIFFV_COORD_MRI)]
```

From what is understand from the [`mne.SourceSpaces.export_volume`](https://mne.tools/stable/generated/mne.SourceSpaces.html#mne.SourceSpaces.export_volume) documentation, , everything should be well aligned, as a `trans`  _Must be provided if source spaces are in head coordinates and include_surfaces and mri_resolution are True._

I have the same issue with my own dataset. Everything works fine (well aligned) with the following script:

```
fig = mne.viz.plot_alignment(
    subject=subject,
    subjects_dir=subjects_dir,
    surfaces="white",
    coord_frame="mri",
    src=src,
)
```
![image](https://github.com/mne-tools/mne-python/assets/28844486/577097ff-8b91-45af-978f-8de0e02be644)

If the issue doesn't come from a misunderstanding from my part, I assume the error to be found in the  `export_volume ` method or in my freeview settings.

### Steps to reproduce

```Python
Download and run the left_cerebellum_volume_source notebook
```


### Link to data

_No response_

### Expected results

The source space should be aligned with the brain (T1,brain,aseg)

### Actual results

The source space are not aligned with the brain (T1,brain,aseg)

head↔MRI

### Additional information

Platform             Windows-10-10.0.19045-SP0
Python               3.11.7 | packaged by Anaconda, Inc. | (main, Dec 15 2023, 18:05:47) [MSC v.1916 64 bit (AMD64)]
Executable           c:\Users\victor.ferat\AppData\Local\miniconda3\envs\meg\python.exe
CPU                  Intel64 Family 6 Model 165 Stepping 2, GenuineIntel (12 cores)
Memory               15.6 GB

Core
├☑ mne               1.6.1 (latest release)
├☑ numpy             1.26.3 (unknown linalg bindings (threadpoolctl module not found: No module named 'threadpoolctl'))
├☑ scipy             1.12.0
├☑ matplotlib        3.8.2 (backend=module://matplotlib_inline.backend_inline)
├☑ pooch             1.8.0
└☑ jinja2            3.1.3

Numerical (optional)
├☑ nibabel           5.2.0
└☐ unavailable       sklearn, numba, nilearn, dipy, openmeeg, cupy, pandas

Visualization (optional)
├☑ pyvista           0.43.2 (OpenGL 4.5.0 - Build 30.0.101.1338 via Intel(R) UHD Graphics)
├☑ pyvistaqt         0.11.0
├☑ vtk               9.3.0
├☑ qtpy              2.4.1 (PyQt6=6.6.1)
├☑ pyqtgraph         0.13.3
├☑ mne-qt-browser    0.6.1
├☑ ipywidgets        8.1.1
└☐ unavailable       ipympl, trame_client, trame_server, trame_vtk, trame_vuetify

Ecosystem (optional)
└☐ unavailable       mne-bids, mne-nirs, mne-features, mne-connectivity, mne-icalabel, mne-bids-pipeline



I'm running freeview from a docker container as  I'm using a windows platform.


Discussion:
Can confirm on `main` with MWE:

```python
from mne import setup_volume_source_space
from mne.datasets import sample
from mne.utils import run_subprocess
from mne.viz import plot_alignment

subjects_dir = sample.data_path() / "subjects"
subject = "sample"
aseg_fname = subjects_dir / subject / "mri" / "aseg.mgz"

# setup a volume source space of the left cerebellum cortex
lh_cereb = setup_volume_source_space(
    subject,
    mri=aseg_fname,
    sphere=(0, 0, 0, 0.12),
    volume_label="Left-Cerebellum-Cortex",
    subjects_dir=subjects_dir,
    sphere_units="m",
)

plot_alignment(
    subject=subject,
    subjects_dir=subjects_dir,
    surfaces="white",
    coord_frame="mri",
    src=lh_cereb,
)

nii_fname = "mne_sample_lh-cerebellum-cortex.nii"
lh_cereb.export_volume(nii_fname, mri_resolution=True, overwrite=True)

mri_fname = subjects_dir / "sample" / "mri" / "brain.mgz"
run_subprocess(
    [
        "freeview",
        "-v",
        str(mri_fname),
        "-v",
        "%s:colormap=lut:opacity=0.5" % str(aseg_fname),
        "-v",
        "%s:colormap=jet:colorscale=0,2" % nii_fname,
        "--slice",
        "157",
        "75",
        "105",
    ]
)
```

And that commented `run_subprocess` command is outdated in the tutorial anyway..

Resolving patch:
diff --git a/mne/source_space/_source_space.py b/mne/source_space/_source_space.py
--- a/mne/source_space/_source_space.py
+++ b/mne/source_space/_source_space.py
@@ -668,10 +668,11 @@ def export_volume(
 
         # Figure out how to get from our input source space to output voxels
         fro_dst_t = invert_transform(transform)
-        dest = transform["to"]
         if coords == "head":
             head_mri_t = _get_trans(trans, "head", "mri")[0]
-            fro_dst_t = combine_transforms(head_mri_t, fro_dst_t, "head", dest)
+            fro_dst_t = combine_transforms(
+                head_mri_t, fro_dst_t, "head", transform["to"]
+            )
         else:
             fro_dst_t = fro_dst_t
 


Test patch:
diff --git a/mne/source_space/tests/test_source_space.py b/mne/source_space/tests/test_source_space.py
--- a/mne/source_space/tests/test_source_space.py
+++ b/mne/source_space/tests/test_source_space.py
@@ -874,6 +874,27 @@ def test_combine_source_spaces(tmp_path):
     with pytest.warns(RuntimeWarning, match="2 surf vertices lay outside"):
         src.export_volume(image_fname, mri_resolution="sparse", overwrite=True)
 
+    # gh-12495
+    image_fname = tmp_path / "temp-image.nii"
+    lh_cereb = mne.setup_volume_source_space(
+        "sample",
+        mri=aseg_fname,
+        volume_label="Left-Cerebellum-Cortex",
+        add_interpolator=False,
+        subjects_dir=subjects_dir,
+    )
+    lh_cereb.export_volume(image_fname, mri_resolution=True)
+    aseg = nib.load(str(aseg_fname))
+    out = nib.load(str(image_fname))
+    assert_allclose(out.affine, aseg.affine)
+    src_data = _get_img_fdata(out).astype(bool)
+    aseg_data = _get_img_fdata(aseg) == 8
+    n_src = src_data.sum()
+    n_aseg = aseg_data.sum()
+    assert n_aseg == n_src
+    n_overlap = (src_data & aseg_data).sum()
+    assert n_src == n_overlap
+
 
 @testing.requires_testing_data
 def test_morph_source_spaces():