Morph source space data. Parameters ---------- stc_from : VolSourceEstimate | VolVectorSourceEstimate | SourceEstimate | VectorSourceEstimate The source estimate to morph. output : str Can be ``'stc'`` (default) or possibly ``'nifti1'``, or
(
self, stc_from, output="stc", mri_resolution=False, mri_space=None, verbose=None
)
| 509 | |
| 510 | @verbose |
| 511 | def apply( |
| 512 | self, stc_from, output="stc", mri_resolution=False, mri_space=None, verbose=None |
| 513 | ): |
| 514 | """Morph source space data. |
| 515 | |
| 516 | Parameters |
| 517 | ---------- |
| 518 | stc_from : VolSourceEstimate | VolVectorSourceEstimate | SourceEstimate | VectorSourceEstimate |
| 519 | The source estimate to morph. |
| 520 | output : str |
| 521 | Can be ``'stc'`` (default) or possibly ``'nifti1'``, or |
| 522 | ``'nifti2'`` when working with a volume source space defined on a |
| 523 | regular grid. |
| 524 | mri_resolution : bool | tuple | int | float |
| 525 | If True the image is saved in MRI resolution. Default False. |
| 526 | |
| 527 | .. warning: If you have many time points the file produced can be |
| 528 | huge. The default is ``mri_resolution=False``. |
| 529 | mri_space : bool | None |
| 530 | Whether the image to world registration should be in mri space. The |
| 531 | default (None) is mri_space=mri_resolution. |
| 532 | %(verbose)s |
| 533 | |
| 534 | Returns |
| 535 | ------- |
| 536 | stc_to : VolSourceEstimate | SourceEstimate | VectorSourceEstimate | Nifti1Image | Nifti2Image |
| 537 | The morphed source estimates. |
| 538 | """ # noqa: E501 |
| 539 | _validate_type(output, str, "output") |
| 540 | _validate_type(stc_from, _BaseSourceEstimate, "stc_from", "source estimate") |
| 541 | if isinstance(stc_from, _BaseSurfaceSourceEstimate): |
| 542 | allowed_kinds = ("stc",) |
| 543 | extra = "when stc is a surface source estimate" |
| 544 | else: |
| 545 | allowed_kinds = ("stc", "nifti1", "nifti2") |
| 546 | extra = "" |
| 547 | _check_option("output", output, allowed_kinds, extra) |
| 548 | stc = copy.deepcopy(stc_from) |
| 549 | |
| 550 | mri_space = mri_resolution if mri_space is None else mri_space |
| 551 | if stc.subject is None: |
| 552 | stc.subject = self.subject_from |
| 553 | if self.subject_from is None: |
| 554 | self.subject_from = stc.subject |
| 555 | if stc.subject != self.subject_from: |
| 556 | raise ValueError( |
| 557 | "stc_from.subject and " |
| 558 | "morph.subject_from " |
| 559 | f"must match. ({stc.subject} != {self.subject_from})" |
| 560 | ) |
| 561 | out = _apply_morph_data(self, stc) |
| 562 | if output != "stc": # convert to volume |
| 563 | out = _morphed_stc_as_volume( |
| 564 | self, |
| 565 | out, |
| 566 | mri_resolution=mri_resolution, |
| 567 | mri_space=mri_space, |
| 568 | output=output, |
nothing calls this directly
no test coverage detected