Synthesize the flash 5 files for use with make_flash_bem. This function aims to produce a synthesized flash 5 MRI from multiecho flash (MEF) MRI data. This function can use MEF data with 5 or 30 flip angles. If flash5 (and flash30) images are not explicitly provided, it will assume
(
subject, flash30=True, unwarp=False, subjects_dir=None, flash5=True, verbose=None
)
| 1944 | |
| 1945 | @verbose |
| 1946 | def convert_flash_mris( |
| 1947 | subject, flash30=True, unwarp=False, subjects_dir=None, flash5=True, verbose=None |
| 1948 | ): |
| 1949 | """Synthesize the flash 5 files for use with make_flash_bem. |
| 1950 | |
| 1951 | This function aims to produce a synthesized flash 5 MRI from |
| 1952 | multiecho flash (MEF) MRI data. This function can use MEF data |
| 1953 | with 5 or 30 flip angles. If flash5 (and flash30) images are not |
| 1954 | explicitly provided, it will assume that the different echos are available |
| 1955 | in the mri/flash folder of the subject with the following naming |
| 1956 | convention "mef<angle>_<echo>.mgz", e.g. "mef05_001.mgz" |
| 1957 | or "mef30_001.mgz". |
| 1958 | |
| 1959 | Parameters |
| 1960 | ---------- |
| 1961 | %(subject)s |
| 1962 | flash30 : bool | list of SpatialImage or path-like | SpatialImage | path-like |
| 1963 | If False do not use 30-degree flip angle data. |
| 1964 | The list of flash 5 echos to use. If True it will look for files |
| 1965 | named mef30_*.mgz in the subject's mri/flash directory and if not False |
| 1966 | the list of flash 5 echos images will be written to the mri/flash |
| 1967 | folder with convention mef05_<echo>.mgz. If a SpatialImage object |
| 1968 | each frame of the image will be interpreted as an echo. |
| 1969 | unwarp : bool |
| 1970 | Run grad_unwarp with -unwarp option on each of the converted |
| 1971 | data sets. It requires FreeSurfer's MATLAB toolbox to be properly |
| 1972 | installed. |
| 1973 | %(subjects_dir)s |
| 1974 | flash5 : list of SpatialImage or path-like | SpatialImage | path-like | True |
| 1975 | The list of flash 5 echos to use. If True it will look for files |
| 1976 | named mef05_*.mgz in the subject's mri/flash directory and if not None |
| 1977 | the list of flash 5 echos images will be written to the mri/flash |
| 1978 | folder with convention mef05_<echo>.mgz. If a SpatialImage object |
| 1979 | each frame of the image will be interpreted as an echo. |
| 1980 | %(verbose)s |
| 1981 | |
| 1982 | Returns |
| 1983 | ------- |
| 1984 | flash5_img : path-like |
| 1985 | The path the synthesized flash 5 MRI. |
| 1986 | |
| 1987 | Notes |
| 1988 | ----- |
| 1989 | This function assumes that the Freesurfer segmentation of the subject |
| 1990 | has been completed. In particular, the T1.mgz and brain.mgz MRI volumes |
| 1991 | should be, as usual, in the subject's mri directory. |
| 1992 | """ # noqa: E501 |
| 1993 | env, mri_dir = _prepare_env(subject, subjects_dir)[:2] |
| 1994 | tempdir = _TempDir() # fsl and Freesurfer create some random junk in CWD |
| 1995 | run_subprocess_env = partial(run_subprocess, env=env, cwd=tempdir) |
| 1996 | |
| 1997 | mri_dir = Path(mri_dir) |
| 1998 | # Step 1a : Data conversion to mgz format |
| 1999 | flash_dir = mri_dir / "flash" |
| 2000 | pm_dir = flash_dir / "parameter_maps" |
| 2001 | pm_dir.mkdir(parents=True, exist_ok=True) |
| 2002 | echos_done = 0 |
| 2003 |