(fid, fwd)
| 914 | |
| 915 | |
| 916 | def _write_forward_solution(fid, fwd): |
| 917 | start_block(fid, FIFF.FIFFB_MNE) |
| 918 | |
| 919 | # |
| 920 | # MNE env |
| 921 | # |
| 922 | start_block(fid, FIFF.FIFFB_MNE_ENV) |
| 923 | write_id(fid, FIFF.FIFF_BLOCK_ID) |
| 924 | data = fwd["info"].get("working_dir", None) |
| 925 | if data is not None: |
| 926 | write_string(fid, FIFF.FIFF_MNE_ENV_WORKING_DIR, data) |
| 927 | data = fwd["info"].get("command_line", None) |
| 928 | if data is not None: |
| 929 | write_string(fid, FIFF.FIFF_MNE_ENV_COMMAND_LINE, data) |
| 930 | end_block(fid, FIFF.FIFFB_MNE_ENV) |
| 931 | |
| 932 | # |
| 933 | # Information from the MRI file |
| 934 | # |
| 935 | start_block(fid, FIFF.FIFFB_MNE_PARENT_MRI_FILE) |
| 936 | write_string(fid, FIFF.FIFF_MNE_FILE_NAME, fwd["info"]["mri_file"]) |
| 937 | if fwd["info"]["mri_id"] is not None: |
| 938 | write_id(fid, FIFF.FIFF_PARENT_FILE_ID, fwd["info"]["mri_id"]) |
| 939 | # store the MRI to HEAD transform in MRI file |
| 940 | write_coord_trans(fid, fwd["info"]["mri_head_t"]) |
| 941 | end_block(fid, FIFF.FIFFB_MNE_PARENT_MRI_FILE) |
| 942 | |
| 943 | # write measurement info |
| 944 | write_forward_meas_info(fid, fwd["info"]) |
| 945 | |
| 946 | # invert our original source space transform |
| 947 | src = fwd["src"].copy() |
| 948 | # returns source space to original coordinate frame, usually MRI |
| 949 | src._transform_to(fwd["mri_head_t"]["from"], fwd["mri_head_t"]) |
| 950 | |
| 951 | # |
| 952 | # Write the source spaces (again) |
| 953 | # |
| 954 | _write_source_spaces_to_fid(fid, src) |
| 955 | n_vert = sum([ss["nuse"] for ss in src]) |
| 956 | if fwd["_orig_source_ori"] == FIFF.FIFFV_MNE_FIXED_ORI: |
| 957 | n_col = n_vert |
| 958 | else: |
| 959 | n_col = 3 * n_vert |
| 960 | |
| 961 | # Undo transformations |
| 962 | sol = fwd["_orig_sol"].copy() |
| 963 | if fwd["sol_grad"] is not None: |
| 964 | sol_grad = fwd["_orig_sol_grad"].copy() |
| 965 | else: |
| 966 | sol_grad = None |
| 967 | |
| 968 | if fwd["surf_ori"] is True: |
| 969 | if fwd["_orig_source_ori"] == FIFF.FIFFV_MNE_FIXED_ORI: |
| 970 | warn( |
| 971 | "The forward solution, which is stored on disk now, is based " |
| 972 | "on a forward solution with fixed orientation. Please note " |
| 973 | "that the transformation to surface-based, fixed orientation " |
no test coverage detected