Write forward solution to a file. Parameters ---------- %(fname_fwd)s fwd : Forward Forward solution. %(overwrite)s %(verbose)s See Also -------- read_forward_solution Notes ----- Forward solutions, which are derived from an original forward
(fname, fwd, overwrite=False, verbose=None)
| 856 | |
| 857 | @verbose |
| 858 | def write_forward_solution(fname, fwd, overwrite=False, verbose=None): |
| 859 | """Write forward solution to a file. |
| 860 | |
| 861 | Parameters |
| 862 | ---------- |
| 863 | %(fname_fwd)s |
| 864 | fwd : Forward |
| 865 | Forward solution. |
| 866 | %(overwrite)s |
| 867 | %(verbose)s |
| 868 | |
| 869 | See Also |
| 870 | -------- |
| 871 | read_forward_solution |
| 872 | |
| 873 | Notes |
| 874 | ----- |
| 875 | Forward solutions, which are derived from an original forward solution with |
| 876 | free orientation, are always stored on disk as forward solution with free |
| 877 | orientation in X/Y/Z RAS coordinates. Transformations (surface orientation, |
| 878 | fixed orientation) will be reverted. To reapply any transformation to the |
| 879 | forward operator please apply :func:`convert_forward_solution` after |
| 880 | reading the forward solution with :func:`read_forward_solution`. |
| 881 | |
| 882 | Forward solutions, which are derived from an original forward solution with |
| 883 | fixed orientation, are stored on disk as forward solution with fixed |
| 884 | surface-based orientations. Please note that the transformation to |
| 885 | surface-based, fixed orientation cannot be reverted after loading the |
| 886 | forward solution with :func:`read_forward_solution`. |
| 887 | """ |
| 888 | check_fname( |
| 889 | fname, |
| 890 | "forward", |
| 891 | ("-fwd.fif", "-fwd.fif.gz", "_fwd.fif", "_fwd.fif.gz", "-fwd.h5", "_fwd.h5"), |
| 892 | ) |
| 893 | |
| 894 | # check for file existence and expand `~` if present |
| 895 | fname = _check_fname(fname, overwrite) |
| 896 | if fname.suffix == ".h5": |
| 897 | _write_forward_hdf5(fname, fwd) |
| 898 | else: |
| 899 | with start_and_end_file(fname) as fid: |
| 900 | _write_forward_solution(fid, fwd) |
| 901 | |
| 902 | |
| 903 | def _write_forward_hdf5(fname, fwd): |