diff --git a/MANIFEST.in b/MANIFEST.in index 612153d940d..9e12649b5fe 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -15,6 +15,7 @@ recursive-include tutorials *.py recursive-include tutorials *.txt recursive-include mne *.py +recursive-include mne *.pyi recursive-include mne/data * recursive-include mne/icons * recursive-include mne/data/helmets * diff --git a/mne/__init__.py b/mne/__init__.py index 97cbedb6de5..d1c53c9eccf 100644 --- a/mne/__init__.py +++ b/mne/__init__.py @@ -1,5 +1,4 @@ """MNE software for MEG and EEG data analysis.""" - # PEP0440 compatible formatted version, see: # https://www.python.org/dev/peps/pep-0440/ # @@ -26,279 +25,7 @@ from ._version import __version__ except ImportError: __version__ = "0.0.0" - - -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[ - "beamformer", - "channels", - "chpi", - "commands", - "coreg", - "cuda", - "datasets", - "decoding", - "defaults", - "dipole", - "epochs", - "event", - "export", - "filter", - "forward", - "gui", - "inverse_sparse", - "io", - "minimum_norm", - "preprocessing", - "report", - "source_space", - "simulation", - "stats", - "surface", - "time_frequency", - "viz", - ], - submod_attrs={ - "_freesurfer": [ - "get_volume_labels_from_aseg", - "head_to_mni", - "head_to_mri", - "read_freesurfer_lut", - "read_lta", - "read_talxfm", - "vertex_to_mni", - ], - "annotations": [ - "Annotations", - "annotations_from_events", - "count_annotations", - "events_from_annotations", - "read_annotations", - ], - "bem": [ - "make_bem_model", - "make_bem_solution", - "make_sphere_model", - "read_bem_solution", - "read_bem_surfaces", - "write_bem_solution", - "write_bem_surfaces", - "write_head_bem", - ], - "channels": [ - "equalize_channels", - "rename_channels", - "find_layout", - "read_vectorview_selection", - ], - "coreg": [ - "create_default_subject", - "scale_bem", - "scale_labels", - "scale_mri", - "scale_source_space", - ], - "cov": [ - "Covariance", - "compute_covariance", - "compute_raw_covariance", - "make_ad_hoc_cov", - "read_cov", - "whiten_evoked", - "write_cov", - ], - "dipole": [ - "Dipole", - "DipoleFixed", - "fit_dipole", - "read_dipole", - ], - "epochs": [ - "BaseEpochs", - "Epochs", - "EpochsArray", - "concatenate_epochs", - "make_fixed_length_epochs", - "read_epochs", - ], - "event": [ - "AcqParserFIF", - "concatenate_events", - "count_events", - "find_events", - "find_stim_steps", - "make_fixed_length_events", - "merge_events", - "pick_events", - "read_events", - "write_events", - ], - "evoked": [ - "Evoked", - "EvokedArray", - "combine_evoked", - "read_evokeds", - "write_evokeds", - ], - "forward": [ - "Forward", - "apply_forward_raw", - "apply_forward", - "average_forward_solutions", - "convert_forward_solution", - "make_field_map", - "make_forward_dipole", - "make_forward_solution", - "read_forward_solution", - "use_coil_def", - "write_forward_solution", - ], - "io": [ - "read_epochs_fieldtrip", - "read_evoked_besa", - "read_evoked_fieldtrip", - "read_evokeds_mff", - ], - "io.base": [ - "concatenate_raws", - "match_channel_orders", - ], - "io.eeglab": [ - "read_epochs_eeglab", - ], - "io.kit": [ - "read_epochs_kit", - ], - "_fiff.meas_info": [ - "Info", - "create_info", - ], - "_fiff.pick": [ - "channel_indices_by_type", - "channel_type", - "pick_channels_cov", - "pick_channels_forward", - "pick_channels_regexp", - "pick_channels", - "pick_info", - "pick_types_forward", - "pick_types", - ], - "_fiff.proj": [ - "Projection", - ], - "_fiff.reference": [ - "add_reference_channels", - "set_bipolar_reference", - "set_eeg_reference", - ], - "_fiff.what": [ - "what", - ], - "label": [ - "BiHemiLabel", - "grow_labels", - "label_sign_flip", - "Label", - "labels_to_stc", - "morph_labels", - "random_parcellation", - "read_label", - "read_labels_from_annot", - "split_label", - "stc_to_label", - "write_label", - "write_labels_to_annot", - ], - "misc": [ - "parse_config", - "read_reject_parameters", - ], - "morph_map": [ - "read_morph_map", - ], - "morph": [ - "SourceMorph", - "compute_source_morph", - "grade_to_vertices", - "read_source_morph", - ], - "proj": [ - "compute_proj_epochs", - "compute_proj_evoked", - "compute_proj_raw", - "read_proj", - "sensitivity_map", - "write_proj", - ], - "rank": [ - "compute_rank", - ], - "report": [ - "Report", - "open_report", - ], - "source_estimate": [ - "MixedSourceEstimate", - "MixedVectorSourceEstimate", - "SourceEstimate", - "VectorSourceEstimate", - "VolSourceEstimate", - "VolVectorSourceEstimate", - "extract_label_time_course", - "grade_to_tris", - "read_source_estimate", - "spatial_dist_adjacency", - "spatial_inter_hemi_adjacency", - "spatial_src_adjacency", - "spatial_tris_adjacency", - "spatio_temporal_dist_adjacency", - "spatio_temporal_src_adjacency", - "spatio_temporal_tris_adjacency", - "stc_near_sensors", - ], - "source_space._source_space": [ - "SourceSpaces", - "add_source_space_distances", - "get_volume_labels_from_src", - "morph_source_spaces", - "read_source_spaces", - "setup_source_space", - "setup_volume_source_space", - "write_source_spaces", - ], - "surface": [ - "decimate_surface", - "dig_mri_distances", - "get_head_surf", - "get_meg_helmet_surf", - "get_montage_volume_labels", - "read_surface", - "read_tri", - "write_surface", - ], - "transforms": [ - "Transform", - "read_trans", - "transform_surface_to", - "write_trans", - ], - "utils": [ - "get_config_path", - "get_config", - "grand_average", - "open_docs", - "set_cache_dir", - "set_config", - "set_memmap_min_size", - "sys_info", - "use_log_level", - "verbose", - ], - }, -) - +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) # initialize logging from .utils import set_log_level, set_log_file diff --git a/mne/__init__.pyi b/mne/__init__.pyi new file mode 100644 index 00000000000..5492a3dfdb5 --- /dev/null +++ b/mne/__init__.pyi @@ -0,0 +1,426 @@ +__all__ = [ + "AcqParserFIF", + "Annotations", + "BaseEpochs", + "BiHemiLabel", + "Covariance", + "Dipole", + "DipoleFixed", + "Epochs", + "EpochsArray", + "Evoked", + "EvokedArray", + "Forward", + "Info", + "Label", + "MixedSourceEstimate", + "MixedVectorSourceEstimate", + "Projection", + "Report", + "SourceEstimate", + "SourceMorph", + "SourceSpaces", + "Transform", + "VectorSourceEstimate", + "VolSourceEstimate", + "VolVectorSourceEstimate", + "add_reference_channels", + "add_source_space_distances", + "annotations_from_events", + "apply_forward", + "apply_forward_raw", + "average_forward_solutions", + "beamformer", + "channel_indices_by_type", + "channel_type", + "channels", + "chpi", + "combine_evoked", + "commands", + "compute_covariance", + "compute_proj_epochs", + "compute_proj_evoked", + "compute_proj_raw", + "compute_rank", + "compute_raw_covariance", + "compute_source_morph", + "concatenate_epochs", + "concatenate_events", + "concatenate_raws", + "convert_forward_solution", + "coreg", + "count_annotations", + "count_events", + "create_default_subject", + "create_info", + "cuda", + "datasets", + "decimate_surface", + "decoding", + "defaults", + "dig_mri_distances", + "dipole", + "epochs", + "equalize_channels", + "event", + "events_from_annotations", + "export", + "extract_label_time_course", + "filter", + "find_events", + "find_layout", + "find_stim_steps", + "fit_dipole", + "forward", + "get_config", + "get_config_path", + "get_head_surf", + "get_meg_helmet_surf", + "get_montage_volume_labels", + "get_volume_labels_from_aseg", + "get_volume_labels_from_src", + "grade_to_tris", + "grade_to_vertices", + "grand_average", + "grow_labels", + "gui", + "head_to_mni", + "head_to_mri", + "inverse_sparse", + "io", + "label_sign_flip", + "labels_to_stc", + "make_ad_hoc_cov", + "make_bem_model", + "make_bem_solution", + "make_field_map", + "make_fixed_length_epochs", + "make_fixed_length_events", + "make_forward_dipole", + "make_forward_solution", + "make_sphere_model", + "match_channel_orders", + "merge_events", + "minimum_norm", + "morph_labels", + "morph_source_spaces", + "open_docs", + "open_report", + "parse_config", + "pick_channels", + "pick_channels_cov", + "pick_channels_forward", + "pick_channels_regexp", + "pick_events", + "pick_info", + "pick_types", + "pick_types_forward", + "preprocessing", + "random_parcellation", + "read_annotations", + "read_bem_solution", + "read_bem_surfaces", + "read_cov", + "read_dipole", + "read_epochs", + "read_epochs_eeglab", + "read_epochs_fieldtrip", + "read_epochs_kit", + "read_events", + "read_evoked_besa", + "read_evoked_fieldtrip", + "read_evokeds", + "read_evokeds_mff", + "read_forward_solution", + "read_freesurfer_lut", + "read_label", + "read_labels_from_annot", + "read_lta", + "read_morph_map", + "read_proj", + "read_reject_parameters", + "read_source_estimate", + "read_source_morph", + "read_source_spaces", + "read_surface", + "read_talxfm", + "read_trans", + "read_tri", + "read_vectorview_selection", + "rename_channels", + "report", + "scale_bem", + "scale_labels", + "scale_mri", + "scale_source_space", + "sensitivity_map", + "set_bipolar_reference", + "set_cache_dir", + "set_config", + "set_eeg_reference", + "set_memmap_min_size", + "setup_source_space", + "setup_volume_source_space", + "simulation", + "source_space", + "spatial_dist_adjacency", + "spatial_inter_hemi_adjacency", + "spatial_src_adjacency", + "spatial_tris_adjacency", + "spatio_temporal_dist_adjacency", + "spatio_temporal_src_adjacency", + "spatio_temporal_tris_adjacency", + "split_label", + "stats", + "stc_near_sensors", + "stc_to_label", + "surface", + "sys_info", + "time_frequency", + "transform_surface_to", + "use_coil_def", + "use_log_level", + "verbose", + "vertex_to_mni", + "viz", + "what", + "whiten_evoked", + "write_bem_solution", + "write_bem_surfaces", + "write_cov", + "write_events", + "write_evokeds", + "write_forward_solution", + "write_head_bem", + "write_label", + "write_labels_to_annot", + "write_proj", + "write_source_spaces", + "write_surface", + "write_trans", +] +from . import ( + beamformer, + channels, + chpi, + commands, + coreg, + cuda, + datasets, + decoding, + defaults, + dipole, + epochs, + event, + export, + filter, + forward, + gui, + inverse_sparse, + io, + minimum_norm, + preprocessing, + report, + source_space, + simulation, + stats, + surface, + time_frequency, + viz, +) +from ._freesurfer import ( + get_volume_labels_from_aseg, + head_to_mni, + head_to_mri, + read_freesurfer_lut, + read_lta, + read_talxfm, + vertex_to_mni, +) +from .annotations import ( + Annotations, + annotations_from_events, + count_annotations, + events_from_annotations, + read_annotations, +) +from .bem import ( + make_bem_model, + make_bem_solution, + make_sphere_model, + read_bem_solution, + read_bem_surfaces, + write_bem_solution, + write_bem_surfaces, + write_head_bem, +) +from .channels import ( + equalize_channels, + rename_channels, + find_layout, + read_vectorview_selection, +) +from .coreg import ( + create_default_subject, + scale_bem, + scale_labels, + scale_mri, + scale_source_space, +) +from .cov import ( + Covariance, + compute_covariance, + compute_raw_covariance, + make_ad_hoc_cov, + read_cov, + whiten_evoked, + write_cov, +) +from .dipole import Dipole, DipoleFixed, fit_dipole, read_dipole +from .epochs import ( + BaseEpochs, + Epochs, + EpochsArray, + concatenate_epochs, + make_fixed_length_epochs, + read_epochs, +) +from .event import ( + AcqParserFIF, + concatenate_events, + count_events, + find_events, + find_stim_steps, + make_fixed_length_events, + merge_events, + pick_events, + read_events, + write_events, +) +from .evoked import Evoked, EvokedArray, combine_evoked, read_evokeds, write_evokeds +from .forward import ( + Forward, + apply_forward_raw, + apply_forward, + average_forward_solutions, + convert_forward_solution, + make_field_map, + make_forward_dipole, + make_forward_solution, + read_forward_solution, + use_coil_def, + write_forward_solution, +) +from .io import ( + read_epochs_fieldtrip, + read_evoked_besa, + read_evoked_fieldtrip, + read_evokeds_mff, +) +from .io.base import concatenate_raws, match_channel_orders +from .io.eeglab import read_epochs_eeglab +from .io.kit import read_epochs_kit +from ._fiff.meas_info import Info, create_info +from ._fiff.pick import ( + channel_indices_by_type, + channel_type, + pick_channels_cov, + pick_channels_forward, + pick_channels_regexp, + pick_channels, + pick_info, + pick_types_forward, + pick_types, +) +from ._fiff.proj import Projection +from ._fiff.reference import ( + add_reference_channels, + set_bipolar_reference, + set_eeg_reference, +) +from ._fiff.what import what +from .label import ( + BiHemiLabel, + grow_labels, + label_sign_flip, + Label, + labels_to_stc, + morph_labels, + random_parcellation, + read_label, + read_labels_from_annot, + split_label, + stc_to_label, + write_label, + write_labels_to_annot, +) +from .misc import parse_config, read_reject_parameters +from .morph_map import read_morph_map +from .morph import ( + SourceMorph, + compute_source_morph, + grade_to_vertices, + read_source_morph, +) +from .proj import ( + compute_proj_epochs, + compute_proj_evoked, + compute_proj_raw, + read_proj, + sensitivity_map, + write_proj, +) +from .rank import compute_rank +from .report import Report, open_report +from .source_estimate import ( + MixedSourceEstimate, + MixedVectorSourceEstimate, + SourceEstimate, + VectorSourceEstimate, + VolSourceEstimate, + VolVectorSourceEstimate, + extract_label_time_course, + grade_to_tris, + read_source_estimate, + spatial_dist_adjacency, + spatial_inter_hemi_adjacency, + spatial_src_adjacency, + spatial_tris_adjacency, + spatio_temporal_dist_adjacency, + spatio_temporal_src_adjacency, + spatio_temporal_tris_adjacency, + stc_near_sensors, +) +from .source_space._source_space import ( + SourceSpaces, + add_source_space_distances, + get_volume_labels_from_src, + morph_source_spaces, + read_source_spaces, + setup_source_space, + setup_volume_source_space, + write_source_spaces, +) +from .surface import ( + decimate_surface, + dig_mri_distances, + get_head_surf, + get_meg_helmet_surf, + get_montage_volume_labels, + read_surface, + read_tri, + write_surface, +) +from .transforms import Transform, read_trans, transform_surface_to, write_trans +from .utils import ( + get_config_path, + get_config, + grand_average, + open_docs, + set_cache_dir, + set_config, + set_memmap_min_size, + sys_info, + use_log_level, + verbose, +) diff --git a/mne/beamformer/__init__.py b/mne/beamformer/__init__.py index fec74e7b229..25c2156e7d0 100644 --- a/mne/beamformer/__init__.py +++ b/mne/beamformer/__init__.py @@ -1,35 +1,4 @@ """Beamformers for source localization.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "_lcmv": [ - "make_lcmv", - "apply_lcmv", - "apply_lcmv_epochs", - "apply_lcmv_raw", - "apply_lcmv_cov", - ], - "_dics": [ - "make_dics", - "apply_dics", - "apply_dics_epochs", - "apply_dics_tfr_epochs", - "apply_dics_csd", - ], - "_rap_music": [ - "rap_music", - "trap_music", - ], - "_compute_beamformer": [ - "Beamformer", - "read_beamformer", - ], - "resolution_matrix": [ - "make_lcmv_resolution_matrix", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/beamformer/__init__.pyi b/mne/beamformer/__init__.pyi new file mode 100644 index 00000000000..68129e9f081 --- /dev/null +++ b/mne/beamformer/__init__.pyi @@ -0,0 +1,34 @@ +__all__ = [ + "Beamformer", + "apply_dics", + "apply_dics_csd", + "apply_dics_epochs", + "apply_dics_tfr_epochs", + "apply_lcmv", + "apply_lcmv_cov", + "apply_lcmv_epochs", + "apply_lcmv_raw", + "make_dics", + "make_lcmv", + "make_lcmv_resolution_matrix", + "rap_music", + "read_beamformer", + "trap_music", +] +from ._lcmv import ( + make_lcmv, + apply_lcmv, + apply_lcmv_epochs, + apply_lcmv_raw, + apply_lcmv_cov, +) +from ._dics import ( + make_dics, + apply_dics, + apply_dics_epochs, + apply_dics_tfr_epochs, + apply_dics_csd, +) +from ._rap_music import rap_music, trap_music +from ._compute_beamformer import Beamformer, read_beamformer +from .resolution_matrix import make_lcmv_resolution_matrix diff --git a/mne/channels/__init__.py b/mne/channels/__init__.py index 3591d7aeeb4..6c63c47525c 100644 --- a/mne/channels/__init__.py +++ b/mne/channels/__init__.py @@ -2,52 +2,6 @@ Can be used for setting of sensor locations used for processing and plotting. """ - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "channels": [ - "equalize_channels", - "rename_channels", - "fix_mag_coil_types", - "read_ch_adjacency", - "find_ch_adjacency", - "make_1020_channel_selections", - "combine_channels", - "read_vectorview_selection", - "_SELECTIONS", - "_EEG_SELECTIONS", - "_divide_to_regions", - "get_builtin_ch_adjacencies", - "unify_bad_channels", - ], - "layout": [ - "Layout", - "make_eeg_layout", - "make_grid_layout", - "read_layout", - "find_layout", - "generate_2d_layout", - ], - "montage": [ - "DigMontage", - "get_builtin_montages", - "make_dig_montage", - "read_dig_dat", - "read_dig_egi", - "read_dig_captrak", - "read_dig_fif", - "read_dig_polhemus_isotrak", - "read_polhemus_fastscan", - "compute_dev_head_t", - "make_standard_montage", - "read_custom_montage", - "read_dig_hpts", - "read_dig_localite", - "compute_native_head_t", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/channels/__init__.pyi b/mne/channels/__init__.pyi new file mode 100644 index 00000000000..bb9c2f96413 --- /dev/null +++ b/mne/channels/__init__.pyi @@ -0,0 +1,76 @@ +__all__ = [ + "DigMontage", + "Layout", + "_EEG_SELECTIONS", + "_SELECTIONS", + "_divide_to_regions", + "combine_channels", + "compute_dev_head_t", + "compute_native_head_t", + "equalize_channels", + "find_ch_adjacency", + "find_layout", + "fix_mag_coil_types", + "generate_2d_layout", + "get_builtin_ch_adjacencies", + "get_builtin_montages", + "make_1020_channel_selections", + "make_dig_montage", + "make_eeg_layout", + "make_grid_layout", + "make_standard_montage", + "read_ch_adjacency", + "read_custom_montage", + "read_dig_captrak", + "read_dig_dat", + "read_dig_egi", + "read_dig_fif", + "read_dig_hpts", + "read_dig_localite", + "read_dig_polhemus_isotrak", + "read_layout", + "read_polhemus_fastscan", + "read_vectorview_selection", + "rename_channels", + "unify_bad_channels", +] +from .channels import ( + equalize_channels, + rename_channels, + fix_mag_coil_types, + read_ch_adjacency, + find_ch_adjacency, + make_1020_channel_selections, + combine_channels, + read_vectorview_selection, + _SELECTIONS, + _EEG_SELECTIONS, + _divide_to_regions, + get_builtin_ch_adjacencies, + unify_bad_channels, +) +from .layout import ( + Layout, + make_eeg_layout, + make_grid_layout, + read_layout, + find_layout, + generate_2d_layout, +) +from .montage import ( + DigMontage, + get_builtin_montages, + make_dig_montage, + read_dig_dat, + read_dig_egi, + read_dig_captrak, + read_dig_fif, + read_dig_polhemus_isotrak, + read_polhemus_fastscan, + compute_dev_head_t, + make_standard_montage, + read_custom_montage, + read_dig_hpts, + read_dig_localite, + compute_native_head_t, +) diff --git a/mne/commands/__init__.py b/mne/commands/__init__.py index 813e2309557..11b3610605d 100644 --- a/mne/commands/__init__.py +++ b/mne/commands/__init__.py @@ -1,9 +1,4 @@ """Command-line utilities.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["utils"], - submod_attrs={}, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/commands/__init__.pyi b/mne/commands/__init__.pyi new file mode 100644 index 00000000000..c0caf04abbb --- /dev/null +++ b/mne/commands/__init__.pyi @@ -0,0 +1,2 @@ +__all__ = ["utils"] +from . import utils diff --git a/mne/datasets/__init__.py b/mne/datasets/__init__.py index 1ff3a0316d2..5c15b0c69d7 100644 --- a/mne/datasets/__init__.py +++ b/mne/datasets/__init__.py @@ -4,45 +4,4 @@ """ import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[ - "fieldtrip_cmc", - "brainstorm", - "visual_92_categories", - "kiloword", - "eegbci", - "hf_sef", - "misc", - "mtrf", - "sample", - "somato", - "multimodal", - "fnirs_motor", - "opm", - "spm_face", - "testing", - "_fake", - "phantom_4dbti", - "sleep_physionet", - "limo", - "refmeg_noise", - "ssvep", - "erp_core", - "epilepsy_ecog", - "eyelink", - "ucl_opm_auditory", - ], - submod_attrs={ - "_fetch": ["fetch_dataset"], - "_fsaverage.base": ["fetch_fsaverage"], - "_infant.base": ["fetch_infant_template"], - "_phantom.base": ["fetch_phantom"], - "utils": [ - "_download_all_example_data", - "fetch_hcp_mmp_parcellation", - "fetch_aparc_sub_parcellation", - "has_dataset", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/datasets/__init__.pyi b/mne/datasets/__init__.pyi new file mode 100644 index 00000000000..96964148d3e --- /dev/null +++ b/mne/datasets/__init__.pyi @@ -0,0 +1,72 @@ +__all__ = [ + "_download_all_example_data", + "_fake", + "brainstorm", + "eegbci", + "epilepsy_ecog", + "erp_core", + "eyelink", + "fetch_aparc_sub_parcellation", + "fetch_dataset", + "fetch_fsaverage", + "fetch_hcp_mmp_parcellation", + "fetch_infant_template", + "fetch_phantom", + "fieldtrip_cmc", + "fnirs_motor", + "has_dataset", + "hf_sef", + "kiloword", + "limo", + "misc", + "mtrf", + "multimodal", + "opm", + "phantom_4dbti", + "refmeg_noise", + "sample", + "sleep_physionet", + "somato", + "spm_face", + "ssvep", + "testing", + "ucl_opm_auditory", + "visual_92_categories", +] +from . import ( + fieldtrip_cmc, + brainstorm, + visual_92_categories, + kiloword, + eegbci, + hf_sef, + misc, + mtrf, + sample, + somato, + multimodal, + fnirs_motor, + opm, + spm_face, + testing, + _fake, + phantom_4dbti, + sleep_physionet, + limo, + refmeg_noise, + ssvep, + erp_core, + epilepsy_ecog, + eyelink, + ucl_opm_auditory, +) +from ._fetch import fetch_dataset +from ._fsaverage.base import fetch_fsaverage +from ._infant.base import fetch_infant_template +from ._phantom.base import fetch_phantom +from .utils import ( + _download_all_example_data, + fetch_hcp_mmp_parcellation, + fetch_aparc_sub_parcellation, + has_dataset, +) diff --git a/mne/decoding/__init__.py b/mne/decoding/__init__.py index 8f83e7875fb..ea140501e26 100644 --- a/mne/decoding/__init__.py +++ b/mne/decoding/__init__.py @@ -1,26 +1,4 @@ """Decoding and encoding, including machine learning and receptive fields.""" import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "base": ["BaseEstimator", "LinearModel", "cross_val_multiscore", "get_coef"], - "csp": ["CSP", "SPoC"], - "ems": ["EMS", "compute_ems"], - "mixin": ["TransformerMixin"], - "receptive_field": ["ReceptiveField"], - "search_light": ["GeneralizingEstimator", "SlidingEstimator"], - "ssd": ["SSD"], - "time_delaying_ridge": ["TimeDelayingRidge"], - "time_frequency": ["TimeFrequency"], - "transformer": [ - "FilterEstimator", - "PSDEstimator", - "Scaler", - "TemporalFilter", - "UnsupervisedSpatialFilter", - "Vectorizer", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/decoding/__init__.pyi b/mne/decoding/__init__.pyi new file mode 100644 index 00000000000..4c37a6bc496 --- /dev/null +++ b/mne/decoding/__init__.pyi @@ -0,0 +1,40 @@ +__all__ = [ + "BaseEstimator", + "CSP", + "EMS", + "FilterEstimator", + "GeneralizingEstimator", + "LinearModel", + "PSDEstimator", + "ReceptiveField", + "SPoC", + "SSD", + "Scaler", + "SlidingEstimator", + "TemporalFilter", + "TimeDelayingRidge", + "TimeFrequency", + "TransformerMixin", + "UnsupervisedSpatialFilter", + "Vectorizer", + "compute_ems", + "cross_val_multiscore", + "get_coef", +] +from .base import BaseEstimator, LinearModel, cross_val_multiscore, get_coef +from .csp import CSP, SPoC +from .ems import EMS, compute_ems +from .mixin import TransformerMixin +from .receptive_field import ReceptiveField +from .search_light import GeneralizingEstimator, SlidingEstimator +from .ssd import SSD +from .time_delaying_ridge import TimeDelayingRidge +from .time_frequency import TimeFrequency +from .transformer import ( + FilterEstimator, + PSDEstimator, + Scaler, + TemporalFilter, + UnsupervisedSpatialFilter, + Vectorizer, +) diff --git a/mne/export/__init__.py b/mne/export/__init__.py index ffaee713afa..eb213750708 100644 --- a/mne/export/__init__.py +++ b/mne/export/__init__.py @@ -1,12 +1,4 @@ """Functions for exporting data to non-FIF formats.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "_export": ["export_raw", "export_epochs", "export_evokeds"], - "_egimff": ["export_evokeds_mff"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/export/__init__.pyi b/mne/export/__init__.pyi new file mode 100644 index 00000000000..e5376ed94e3 --- /dev/null +++ b/mne/export/__init__.pyi @@ -0,0 +1,3 @@ +__all__ = ["export_epochs", "export_evokeds", "export_evokeds_mff", "export_raw"] +from ._export import export_raw, export_epochs, export_evokeds +from ._egimff import export_evokeds_mff diff --git a/mne/forward/__init__.py b/mne/forward/__init__.py index 7738ca51090..4b16f0ab55d 100644 --- a/mne/forward/__init__.py +++ b/mne/forward/__init__.py @@ -1,55 +1,4 @@ """Forward modeling code.""" +import lazy_loader as lazy # for testing purposes -import lazy_loader as lazy - -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["_lead_dots"], # for testing purposes - submod_attrs={ - "forward": [ - "Forward", - "read_forward_solution", - "write_forward_solution", - "is_fixed_orient", - "_read_forward_meas_info", - "_select_orient_forward", - "compute_orient_prior", - "compute_depth_prior", - "apply_forward", - "apply_forward_raw", - "restrict_forward_to_stc", - "restrict_forward_to_label", - "average_forward_solutions", - "_stc_src_sel", - "_fill_measurement_info", - "_apply_forward", - "_subject_from_forward", - "convert_forward_solution", - "_merge_fwds", - "_do_forward_solution", - ], - "_compute_forward": [ - "_magnetic_dipole_field_vec", - "_compute_forwards", - "_concatenate_coils", - ], - "_field_interpolation": [ - "_make_surface_mapping", - "make_field_map", - "_as_meg_type_inst", - "_map_meg_or_eeg_channels", - ], - "_make_forward": [ - "make_forward_solution", - "_prepare_for_forward", - "_prep_meg_channels", - "_prep_eeg_channels", - "_to_forward_dict", - "_create_meg_coils", - "_read_coil_defs", - "_transform_orig_meg_coils", - "make_forward_dipole", - "use_coil_def", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/forward/__init__.pyi b/mne/forward/__init__.pyi new file mode 100644 index 00000000000..36d35b913ca --- /dev/null +++ b/mne/forward/__init__.pyi @@ -0,0 +1,86 @@ +__all__ = [ + "Forward", + "_apply_forward", + "_as_meg_type_inst", + "_compute_forwards", + "_concatenate_coils", + "_create_meg_coils", + "_do_forward_solution", + "_fill_measurement_info", + "_lead_dots", + "_magnetic_dipole_field_vec", + "_make_surface_mapping", + "_map_meg_or_eeg_channels", + "_merge_fwds", + "_prep_eeg_channels", + "_prep_meg_channels", + "_prepare_for_forward", + "_read_coil_defs", + "_read_forward_meas_info", + "_select_orient_forward", + "_stc_src_sel", + "_subject_from_forward", + "_to_forward_dict", + "_transform_orig_meg_coils", + "apply_forward", + "apply_forward_raw", + "average_forward_solutions", + "compute_depth_prior", + "compute_orient_prior", + "convert_forward_solution", + "is_fixed_orient", + "make_field_map", + "make_forward_dipole", + "make_forward_solution", + "read_forward_solution", + "restrict_forward_to_label", + "restrict_forward_to_stc", + "use_coil_def", + "write_forward_solution", +] +from . import _lead_dots +from .forward import ( + Forward, + read_forward_solution, + write_forward_solution, + is_fixed_orient, + _read_forward_meas_info, + _select_orient_forward, + compute_orient_prior, + compute_depth_prior, + apply_forward, + apply_forward_raw, + restrict_forward_to_stc, + restrict_forward_to_label, + average_forward_solutions, + _stc_src_sel, + _fill_measurement_info, + _apply_forward, + _subject_from_forward, + convert_forward_solution, + _merge_fwds, + _do_forward_solution, +) +from ._compute_forward import ( + _magnetic_dipole_field_vec, + _compute_forwards, + _concatenate_coils, +) +from ._field_interpolation import ( + _make_surface_mapping, + make_field_map, + _as_meg_type_inst, + _map_meg_or_eeg_channels, +) +from ._make_forward import ( + make_forward_solution, + _prepare_for_forward, + _prep_meg_channels, + _prep_eeg_channels, + _to_forward_dict, + _create_meg_coils, + _read_coil_defs, + _transform_orig_meg_coils, + make_forward_dipole, + use_coil_def, +) diff --git a/mne/gui/__init__.py b/mne/gui/__init__.py index c3a5b9aada5..3f7a393c4ac 100644 --- a/mne/gui/__init__.py +++ b/mne/gui/__init__.py @@ -1,9 +1,4 @@ """Convenience functions for opening GUIs.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={"_gui": ["coregistration", "_GUIScraper"]}, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/gui/__init__.pyi b/mne/gui/__init__.pyi new file mode 100644 index 00000000000..77a7310e4ad --- /dev/null +++ b/mne/gui/__init__.pyi @@ -0,0 +1,2 @@ +__all__ = ["_GUIScraper", "coregistration"] +from ._gui import coregistration, _GUIScraper diff --git a/mne/html_templates/__init__.py b/mne/html_templates/__init__.py index 22690df3076..851c785db58 100644 --- a/mne/html_templates/__init__.py +++ b/mne/html_templates/__init__.py @@ -1,9 +1,4 @@ """Jinja2 HTML templates.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={"_templates": ["_get_html_template"]}, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/html_templates/__init__.pyi b/mne/html_templates/__init__.pyi new file mode 100644 index 00000000000..2312227d990 --- /dev/null +++ b/mne/html_templates/__init__.pyi @@ -0,0 +1,2 @@ +__all__ = ["_get_html_template"] +from ._templates import _get_html_template diff --git a/mne/inverse_sparse/__init__.py b/mne/inverse_sparse/__init__.py index 4310e1d224a..134b2f3496c 100644 --- a/mne/inverse_sparse/__init__.py +++ b/mne/inverse_sparse/__init__.py @@ -1,16 +1,7 @@ """Non-Linear sparse inverse solvers.""" - # Author: Alexandre Gramfort # # License: Simplified BSD - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "mxne_inverse": ["mixed_norm", "tf_mixed_norm", "make_stc_from_dipoles"], - "_gamma_map": ["gamma_map"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/inverse_sparse/__init__.pyi b/mne/inverse_sparse/__init__.pyi new file mode 100644 index 00000000000..5cd096d92c1 --- /dev/null +++ b/mne/inverse_sparse/__init__.pyi @@ -0,0 +1,3 @@ +__all__ = ["gamma_map", "make_stc_from_dipoles", "mixed_norm", "tf_mixed_norm"] +from .mxne_inverse import mixed_norm, tf_mixed_norm, make_stc_from_dipoles +from ._gamma_map import gamma_map diff --git a/mne/io/__init__.py b/mne/io/__init__.py index fbf10cb403d..ba7f3113794 100644 --- a/mne/io/__init__.py +++ b/mne/io/__init__.py @@ -1,59 +1,8 @@ """IO module for reading raw data.""" - # Authors: Alexandre Gramfort # Matti Hämäläinen # # License: BSD-3-Clause - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[ - "constants", - "pick", - ], - submod_attrs={ - "base": ["BaseRaw", "concatenate_raws", "match_channel_orders"], - "array": ["RawArray"], - "besa": ["read_evoked_besa"], - "brainvision": ["read_raw_brainvision"], - "bti": ["read_raw_bti"], - "cnt": ["read_raw_cnt"], - "ctf": ["read_raw_ctf"], - "curry": ["read_raw_curry"], - "edf": ["read_raw_edf", "read_raw_bdf", "read_raw_gdf"], - "egi": ["read_raw_egi", "read_evokeds_mff"], - "kit": ["read_raw_kit", "read_epochs_kit"], - "fiff": ["read_raw_fif", "Raw"], - "fil": ["read_raw_fil"], - "nedf": ["read_raw_nedf"], - "nicolet": ["read_raw_nicolet"], - "artemis123": ["read_raw_artemis123"], - "eeglab": ["read_raw_eeglab", "read_epochs_eeglab"], - "eximia": ["read_raw_eximia"], - "hitachi": ["read_raw_hitachi"], - "nirx": ["read_raw_nirx"], - "boxy": ["read_raw_boxy"], - "snirf": ["read_raw_snirf"], - "persyst": ["read_raw_persyst"], - "fieldtrip": [ - "read_raw_fieldtrip", - "read_epochs_fieldtrip", - "read_evoked_fieldtrip", - ], - "nihon": ["read_raw_nihon"], - "nsx": ["read_raw_nsx"], - "_read_raw": ["read_raw"], - "eyelink": ["read_raw_eyelink"], - "_fiff_wrap": [ - "read_info", - "write_info", - "anonymize_info", - "read_fiducials", - "write_fiducials", - "show_fiff", - "get_channel_type_constants", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/io/__init__.pyi b/mne/io/__init__.pyi new file mode 100644 index 00000000000..e7fba58667a --- /dev/null +++ b/mne/io/__init__.pyi @@ -0,0 +1,87 @@ +__all__ = [ + "BaseRaw", + "Raw", + "RawArray", + "anonymize_info", + "concatenate_raws", + "constants", + "get_channel_type_constants", + "match_channel_orders", + "pick", + "read_epochs_eeglab", + "read_epochs_fieldtrip", + "read_epochs_kit", + "read_evoked_besa", + "read_evoked_fieldtrip", + "read_evokeds_mff", + "read_fiducials", + "read_info", + "read_raw", + "read_raw_artemis123", + "read_raw_bdf", + "read_raw_boxy", + "read_raw_brainvision", + "read_raw_bti", + "read_raw_cnt", + "read_raw_ctf", + "read_raw_curry", + "read_raw_edf", + "read_raw_eeglab", + "read_raw_egi", + "read_raw_eximia", + "read_raw_eyelink", + "read_raw_fieldtrip", + "read_raw_fif", + "read_raw_fil", + "read_raw_gdf", + "read_raw_hitachi", + "read_raw_kit", + "read_raw_nedf", + "read_raw_nicolet", + "read_raw_nihon", + "read_raw_nirx", + "read_raw_nsx", + "read_raw_persyst", + "read_raw_snirf", + "show_fiff", + "write_fiducials", + "write_info", +] +from . import constants, pick +from .base import BaseRaw, concatenate_raws, match_channel_orders +from .array import RawArray +from .besa import read_evoked_besa +from .brainvision import read_raw_brainvision +from .bti import read_raw_bti +from .cnt import read_raw_cnt +from .ctf import read_raw_ctf +from .curry import read_raw_curry +from .edf import read_raw_edf, read_raw_bdf, read_raw_gdf +from .egi import read_raw_egi, read_evokeds_mff +from .kit import read_raw_kit, read_epochs_kit +from .fiff import read_raw_fif, Raw +from .fil import read_raw_fil +from .nedf import read_raw_nedf +from .nicolet import read_raw_nicolet +from .artemis123 import read_raw_artemis123 +from .eeglab import read_raw_eeglab, read_epochs_eeglab +from .eximia import read_raw_eximia +from .hitachi import read_raw_hitachi +from .nirx import read_raw_nirx +from .boxy import read_raw_boxy +from .snirf import read_raw_snirf +from .persyst import read_raw_persyst +from .fieldtrip import read_raw_fieldtrip, read_epochs_fieldtrip, read_evoked_fieldtrip +from .nihon import read_raw_nihon +from .nsx import read_raw_nsx +from ._read_raw import read_raw +from .eyelink import read_raw_eyelink +from ._fiff_wrap import ( + read_info, + write_info, + anonymize_info, + read_fiducials, + write_fiducials, + show_fiff, + get_channel_type_constants, +) diff --git a/mne/minimum_norm/__init__.py b/mne/minimum_norm/__init__.py index 16d942fabaf..cb1308d9768 100644 --- a/mne/minimum_norm/__init__.py +++ b/mne/minimum_norm/__init__.py @@ -1,37 +1,4 @@ """Linear inverse solvers based on L2 Minimum Norm Estimates (MNE).""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "inverse": [ - "InverseOperator", - "read_inverse_operator", - "apply_inverse", - "apply_inverse_raw", - "make_inverse_operator", - "apply_inverse_epochs", - "apply_inverse_tfr_epochs", - "write_inverse_operator", - "compute_rank_inverse", - "prepare_inverse_operator", - "estimate_snr", - "apply_inverse_cov", - "INVERSE_METHODS", - ], - "time_frequency": [ - "source_band_induced_power", - "source_induced_power", - "compute_source_psd", - "compute_source_psd_epochs", - ], - "resolution_matrix": [ - "make_inverse_resolution_matrix", - "get_point_spread", - "get_cross_talk", - ], - "spatial_resolution": ["resolution_metrics"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/minimum_norm/__init__.pyi b/mne/minimum_norm/__init__.pyi new file mode 100644 index 00000000000..bf8e3fc90ca --- /dev/null +++ b/mne/minimum_norm/__init__.pyi @@ -0,0 +1,50 @@ +__all__ = [ + "INVERSE_METHODS", + "InverseOperator", + "apply_inverse", + "apply_inverse_cov", + "apply_inverse_epochs", + "apply_inverse_raw", + "apply_inverse_tfr_epochs", + "compute_rank_inverse", + "compute_source_psd", + "compute_source_psd_epochs", + "estimate_snr", + "get_cross_talk", + "get_point_spread", + "make_inverse_operator", + "make_inverse_resolution_matrix", + "prepare_inverse_operator", + "read_inverse_operator", + "resolution_metrics", + "source_band_induced_power", + "source_induced_power", + "write_inverse_operator", +] +from .inverse import ( + InverseOperator, + read_inverse_operator, + apply_inverse, + apply_inverse_raw, + make_inverse_operator, + apply_inverse_epochs, + apply_inverse_tfr_epochs, + write_inverse_operator, + compute_rank_inverse, + prepare_inverse_operator, + estimate_snr, + apply_inverse_cov, + INVERSE_METHODS, +) +from .time_frequency import ( + source_band_induced_power, + source_induced_power, + compute_source_psd, + compute_source_psd_epochs, +) +from .resolution_matrix import ( + make_inverse_resolution_matrix, + get_point_spread, + get_cross_talk, +) +from .spatial_resolution import resolution_metrics diff --git a/mne/preprocessing/__init__.py b/mne/preprocessing/__init__.py index 372df010e8c..8a32cd31332 100644 --- a/mne/preprocessing/__init__.py +++ b/mne/preprocessing/__init__.py @@ -1,60 +1,10 @@ """Preprocessing with artifact detection, SSP, and ICA.""" - # Authors: Alexandre Gramfort # Matti Hämäläinen # Martin Luessi # Denis Engemann # # License: BSD-3-Clause - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["eyetracking", "ieeg", "nirs"], - submod_attrs={ - "_annotate_amplitude": ["annotate_amplitude"], - "maxfilter": ["apply_maxfilter"], - "ssp": ["compute_proj_ecg", "compute_proj_eog"], - "eog": ["find_eog_events", "create_eog_epochs"], - "ecg": ["find_ecg_events", "create_ecg_epochs"], - "ica": [ - "ICA", - "ica_find_eog_events", - "ica_find_ecg_events", - "get_score_funcs", - "read_ica", - "corrmap", - "read_ica_eeglab", - ], - "otp": ["oversampled_temporal_projection"], - "_peak_finder": ["peak_finder"], - "infomax_": ["infomax"], - "stim": ["fix_stim_artifact"], - "maxwell": [ - "maxwell_filter", - "find_bad_channels_maxwell", - "compute_maxwell_basis", - "maxwell_filter_prepare_emptyroom", - ], - "realign": ["realign_raw"], - "xdawn": ["Xdawn"], - "_csd": ["compute_current_source_density", "compute_bridged_electrodes"], - "artifact_detection": [ - "annotate_movement", - "compute_average_dev_head_t", - "annotate_muscle_zscore", - "annotate_break", - ], - "_regress": ["regress_artifact", "EOGRegression", "read_eog_regression"], - "_fine_cal": [ - "compute_fine_calibration", - "read_fine_calibration", - "write_fine_calibration", - ], - "_annotate_nan": ["annotate_nan"], - "interpolate": ["equalize_bads", "interpolate_bridged_electrodes"], - "_css": ["cortical_signal_suppression"], - "hfc": ["compute_proj_hfc"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/preprocessing/__init__.pyi b/mne/preprocessing/__init__.pyi new file mode 100644 index 00000000000..bd4dd7f44c4 --- /dev/null +++ b/mne/preprocessing/__init__.pyi @@ -0,0 +1,91 @@ +__all__ = [ + "EOGRegression", + "ICA", + "Xdawn", + "annotate_amplitude", + "annotate_break", + "annotate_movement", + "annotate_muscle_zscore", + "annotate_nan", + "apply_maxfilter", + "compute_average_dev_head_t", + "compute_bridged_electrodes", + "compute_current_source_density", + "compute_fine_calibration", + "compute_maxwell_basis", + "compute_proj_ecg", + "compute_proj_eog", + "compute_proj_hfc", + "corrmap", + "cortical_signal_suppression", + "create_ecg_epochs", + "create_eog_epochs", + "equalize_bads", + "eyetracking", + "find_bad_channels_maxwell", + "find_ecg_events", + "find_eog_events", + "fix_stim_artifact", + "get_score_funcs", + "ica_find_ecg_events", + "ica_find_eog_events", + "ieeg", + "infomax", + "interpolate_bridged_electrodes", + "maxwell_filter", + "maxwell_filter_prepare_emptyroom", + "nirs", + "oversampled_temporal_projection", + "peak_finder", + "read_eog_regression", + "read_fine_calibration", + "read_ica", + "read_ica_eeglab", + "realign_raw", + "regress_artifact", + "write_fine_calibration", +] +from . import eyetracking, ieeg, nirs +from ._annotate_amplitude import annotate_amplitude +from .maxfilter import apply_maxfilter +from .ssp import compute_proj_ecg, compute_proj_eog +from .eog import find_eog_events, create_eog_epochs +from .ecg import find_ecg_events, create_ecg_epochs +from .ica import ( + ICA, + ica_find_eog_events, + ica_find_ecg_events, + get_score_funcs, + read_ica, + corrmap, + read_ica_eeglab, +) +from .otp import oversampled_temporal_projection +from ._peak_finder import peak_finder +from .infomax_ import infomax +from .stim import fix_stim_artifact +from .maxwell import ( + maxwell_filter, + find_bad_channels_maxwell, + compute_maxwell_basis, + maxwell_filter_prepare_emptyroom, +) +from .realign import realign_raw +from .xdawn import Xdawn +from ._csd import compute_current_source_density, compute_bridged_electrodes +from .artifact_detection import ( + annotate_movement, + compute_average_dev_head_t, + annotate_muscle_zscore, + annotate_break, +) +from ._regress import regress_artifact, EOGRegression, read_eog_regression +from ._fine_cal import ( + compute_fine_calibration, + read_fine_calibration, + write_fine_calibration, +) +from ._annotate_nan import annotate_nan +from .interpolate import equalize_bads, interpolate_bridged_electrodes +from ._css import cortical_signal_suppression +from .hfc import compute_proj_hfc diff --git a/mne/report/__init__.py b/mne/report/__init__.py index c5ae0eaadd2..0037b496551 100644 --- a/mne/report/__init__.py +++ b/mne/report/__init__.py @@ -1,11 +1,4 @@ """Report-generation functions and classes.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "report": ["Report", "open_report", "_ReportScraper"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/report/__init__.pyi b/mne/report/__init__.pyi new file mode 100644 index 00000000000..5f62e1eafbf --- /dev/null +++ b/mne/report/__init__.pyi @@ -0,0 +1,2 @@ +__all__ = ["Report", "_ReportScraper", "open_report"] +from .report import Report, open_report, _ReportScraper diff --git a/mne/simulation/__init__.py b/mne/simulation/__init__.py index 045d563273c..cfefe8658ac 100644 --- a/mne/simulation/__init__.py +++ b/mne/simulation/__init__.py @@ -1,18 +1,4 @@ """Data simulation code.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["metrics"], - submod_attrs={ - "evoked": ["simulate_evoked", "add_noise"], - "raw": ["simulate_raw", "add_ecg", "add_eog", "add_chpi"], - "source": [ - "select_source_in_label", - "simulate_stc", - "simulate_sparse_stc", - "SourceSimulator", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/simulation/__init__.pyi b/mne/simulation/__init__.pyi new file mode 100644 index 00000000000..1a49e48a882 --- /dev/null +++ b/mne/simulation/__init__.pyi @@ -0,0 +1,22 @@ +__all__ = [ + "SourceSimulator", + "add_chpi", + "add_ecg", + "add_eog", + "add_noise", + "metrics", + "select_source_in_label", + "simulate_evoked", + "simulate_raw", + "simulate_sparse_stc", + "simulate_stc", +] +from . import metrics +from .evoked import simulate_evoked, add_noise +from .raw import simulate_raw, add_ecg, add_eog, add_chpi +from .source import ( + select_source_in_label, + simulate_stc, + simulate_sparse_stc, + SourceSimulator, +) diff --git a/mne/source_space/__init__.py b/mne/source_space/__init__.py index 42506025869..eca8b7f74c9 100644 --- a/mne/source_space/__init__.py +++ b/mne/source_space/__init__.py @@ -1,22 +1,4 @@ """Forward modeling code.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["_source_space"], - submod_attrs={ - "_source_space": [ - "compute_distance_to_sensors", - "get_decimated_surfaces", - # These are documented in the MNE namespace but it doesn't hurt to - # keep them here as well - "SourceSpaces", - "read_source_spaces", - "write_source_spaces", - "setup_source_space", - "setup_volume_source_space", - "add_source_space_distances", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/source_space/__init__.pyi b/mne/source_space/__init__.pyi new file mode 100644 index 00000000000..fab90945882 --- /dev/null +++ b/mne/source_space/__init__.pyi @@ -0,0 +1,22 @@ +__all__ = [ + "SourceSpaces", + "_source_space", + "add_source_space_distances", + "compute_distance_to_sensors", + "get_decimated_surfaces", + "read_source_spaces", + "setup_source_space", + "setup_volume_source_space", + "write_source_spaces", +] +from . import _source_space +from ._source_space import ( + compute_distance_to_sensors, + get_decimated_surfaces, + SourceSpaces, + read_source_spaces, + write_source_spaces, + setup_source_space, + setup_volume_source_space, + add_source_space_distances, +) diff --git a/mne/stats/__init__.py b/mne/stats/__init__.py index 9a1ed38518e..7c4f1454a9b 100644 --- a/mne/stats/__init__.py +++ b/mne/stats/__init__.py @@ -1,34 +1,4 @@ """Functions for statistical analysis.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "parametric": [ - "f_threshold_mway_rm", - "f_mway_rm", - "f_oneway", - "_parametric_ci", - "ttest_1samp_no_p", - "ttest_ind_no_p", - ], - "permutations": [ - "permutation_t_test", - "_ci", - "bootstrap_confidence_interval", - ], - "cluster_level": [ - "permutation_cluster_test", - "permutation_cluster_1samp_test", - "spatio_temporal_cluster_test", - "spatio_temporal_cluster_1samp_test", - "_st_mask_from_s_inds", - "summarize_clusters_stc", - ], - "multi_comp": ["fdr_correction", "bonferroni_correction"], - "regression": ["linear_regression", "linear_regression_raw"], - "_adjacency": ["combine_adjacency"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/stats/__init__.pyi b/mne/stats/__init__.pyi new file mode 100644 index 00000000000..ac47d6c3680 --- /dev/null +++ b/mne/stats/__init__.pyi @@ -0,0 +1,42 @@ +__all__ = [ + "_ci", + "_parametric_ci", + "_st_mask_from_s_inds", + "bonferroni_correction", + "bootstrap_confidence_interval", + "combine_adjacency", + "f_mway_rm", + "f_oneway", + "f_threshold_mway_rm", + "fdr_correction", + "linear_regression", + "linear_regression_raw", + "permutation_cluster_1samp_test", + "permutation_cluster_test", + "permutation_t_test", + "spatio_temporal_cluster_1samp_test", + "spatio_temporal_cluster_test", + "summarize_clusters_stc", + "ttest_1samp_no_p", + "ttest_ind_no_p", +] +from .parametric import ( + f_threshold_mway_rm, + f_mway_rm, + f_oneway, + _parametric_ci, + ttest_1samp_no_p, + ttest_ind_no_p, +) +from .permutations import permutation_t_test, _ci, bootstrap_confidence_interval +from .cluster_level import ( + permutation_cluster_test, + permutation_cluster_1samp_test, + spatio_temporal_cluster_test, + spatio_temporal_cluster_1samp_test, + _st_mask_from_s_inds, + summarize_clusters_stc, +) +from .multi_comp import fdr_correction, bonferroni_correction +from .regression import linear_regression, linear_regression_raw +from ._adjacency import combine_adjacency diff --git a/mne/time_frequency/__init__.py b/mne/time_frequency/__init__.py index 8f245bee7f6..c95662bbc26 100644 --- a/mne/time_frequency/__init__.py +++ b/mne/time_frequency/__init__.py @@ -1,57 +1,4 @@ """Time frequency analysis tools.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "_stft": [ - "istft", - "stft", - "stftfreq", - ], - "_stockwell": [ - "tfr_array_stockwell", - "tfr_stockwell", - ], - "ar": ["fit_iir_model_raw"], - "csd": [ - "CrossSpectralDensity", - "csd_array_fourier", - "csd_array_morlet", - "csd_array_multitaper", - "csd_fourier", - "csd_morlet", - "csd_multitaper", - "csd_tfr", - "pick_channels_csd", - "read_csd", - ], - "multitaper": [ - "dpss_windows", - "psd_array_multitaper", - "tfr_array_multitaper", - ], - "psd": ["psd_array_welch"], - "spectrum": [ - "EpochsSpectrum", - "EpochsSpectrumArray", - "Spectrum", - "SpectrumArray", - "read_spectrum", - ], - "tfr": [ - "_BaseTFR", - "AverageTFR", - "EpochsTFR", - "fwhm", - "morlet", - "read_tfrs", - "tfr_array_morlet", - "tfr_morlet", - "tfr_multitaper", - "write_tfrs", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/time_frequency/__init__.pyi b/mne/time_frequency/__init__.pyi new file mode 100644 index 00000000000..258fa5ef96c --- /dev/null +++ b/mne/time_frequency/__init__.pyi @@ -0,0 +1,73 @@ +__all__ = [ + "AverageTFR", + "CrossSpectralDensity", + "EpochsSpectrum", + "EpochsSpectrumArray", + "EpochsTFR", + "Spectrum", + "SpectrumArray", + "_BaseTFR", + "csd_array_fourier", + "csd_array_morlet", + "csd_array_multitaper", + "csd_fourier", + "csd_morlet", + "csd_multitaper", + "csd_tfr", + "dpss_windows", + "fit_iir_model_raw", + "fwhm", + "istft", + "morlet", + "pick_channels_csd", + "psd_array_multitaper", + "psd_array_welch", + "read_csd", + "read_spectrum", + "read_tfrs", + "stft", + "stftfreq", + "tfr_array_morlet", + "tfr_array_multitaper", + "tfr_array_stockwell", + "tfr_morlet", + "tfr_multitaper", + "tfr_stockwell", + "write_tfrs", +] +from ._stft import istft, stft, stftfreq +from ._stockwell import tfr_array_stockwell, tfr_stockwell +from .ar import fit_iir_model_raw +from .csd import ( + CrossSpectralDensity, + csd_array_fourier, + csd_array_morlet, + csd_array_multitaper, + csd_fourier, + csd_morlet, + csd_multitaper, + csd_tfr, + pick_channels_csd, + read_csd, +) +from .multitaper import dpss_windows, psd_array_multitaper, tfr_array_multitaper +from .psd import psd_array_welch +from .spectrum import ( + EpochsSpectrum, + EpochsSpectrumArray, + Spectrum, + SpectrumArray, + read_spectrum, +) +from .tfr import ( + _BaseTFR, + AverageTFR, + EpochsTFR, + fwhm, + morlet, + read_tfrs, + tfr_array_morlet, + tfr_morlet, + tfr_multitaper, + write_tfrs, +) diff --git a/mne/utils/__init__.py b/mne/utils/__init__.py index 76e52f378fe..f84944aae4a 100644 --- a/mne/utils/__init__.py +++ b/mne/utils/__init__.py @@ -1,208 +1,3 @@ import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=[], - submod_attrs={ - "_bunch": ["Bunch", "BunchConst", "BunchConstNamed"], - "check": [ - "check_fname", - "check_version", - "check_random_state", - "_check_fname", - "_check_subject", - "_check_pandas_installed", - "_check_pandas_index_arguments", - "_check_event_id", - "_check_ch_locs", - "_check_compensation_grade", - "_check_if_nan", - "_is_numeric", - "_ensure_int", - "_check_integer_or_list", - "_check_preload", - "_validate_type", - "_check_range", - "_check_info_inv", - "_check_channels_spatial_filter", - "_check_one_ch_type", - "_check_rank", - "_check_option", - "_check_depth", - "_check_combine", - "_path_like", - "_check_src_normal", - "_check_stc_units", - "_check_qt_version", - "_check_sphere", - "_check_time_format", - "_check_freesurfer_home", - "_suggest", - "_require_version", - "_on_missing", - "_check_on_missing", - "int_like", - "_safe_input", - "_check_all_same_channel_names", - "path_like", - "_ensure_events", - "_check_eeglabio_installed", - "_check_pybv_installed", - "_check_edflib_installed", - "_to_rgb", - "_soft_import", - "_check_dict_keys", - "_check_pymatreader_installed", - "_import_h5py", - "_import_h5io_funcs", - "_import_nibabel", - "_import_pymatreader_funcs", - "_check_head_radius", - ], - "config": [ - "set_config", - "get_config", - "get_config_path", - "set_cache_dir", - "set_memmap_min_size", - "get_subjects_dir", - "_get_stim_channel", - "sys_info", - "_get_extra_data_path", - "_get_root_dir", - "_get_numpy_libs", - ], - "docs": [ - "copy_function_doc_to_method_doc", - "copy_doc", - "linkcode_resolve", - "open_docs", - "deprecated", - "fill_doc", - "deprecated_alias", - "legacy", - "copy_base_doc_to_subclass_doc", - "_doc_special_members", - ], - "fetching": ["_url_to_local_path"], - "_logging": [ - "verbose", - "logger", - "set_log_level", - "set_log_file", - "use_log_level", - "catch_logging", - "warn", - "filter_out_warnings", - "wrapped_stdout", - "_get_call_line", - "_record_warnings", - "ClosingStringIO", - "_verbose_safe_false", - "_parse_verbose", - ], - "misc": [ - "run_subprocess", - "_pl", - "_clean_names", - "pformat", - "_file_like", - "_empty_hash", - "_explain_exception", - "_get_argvalues", - "sizeof_fmt", - "running_subprocess", - "_DefaultEventParser", - "_assert_no_instances", - "_resource_path", - "repr_html", - "_auto_weakref", - ], - "progressbar": ["ProgressBar"], - "_testing": [ - "run_command_if_main", - "requires_mne", - "requires_good_network", - "ArgvSetter", - "SilenceStdout", - "has_freesurfer", - "has_mne_c", - "_TempDir", - "buggy_mkl_svd", - "requires_freesurfer", - "requires_mne_mark", - "assert_object_equal", - "assert_and_remove_boundary_annot", - "_raw_annot", - "assert_dig_allclose", - "assert_meg_snr", - "assert_snr", - "assert_stcs_equal", - "_click_ch_name", - "requires_openmeeg_mark", - ], - "numerics": [ - "hashfunc", - "_compute_row_norms", - "_reg_pinv", - "random_permutation", - "_reject_data_segments", - "compute_corr", - "_get_inst_data", - "array_split_idx", - "sum_squared", - "split_list", - "_gen_events", - "create_slices", - "_time_mask", - "_freq_mask", - "grand_average", - "object_diff", - "object_hash", - "object_size", - "_apply_scaling_cov", - "_undo_scaling_cov", - "_apply_scaling_array", - "_undo_scaling_array", - "_scaled_array", - "_replace_md5", - "_PCA", - "_mask_to_onsets_offsets", - "_array_equal_nan", - "_julian_to_cal", - "_cal_to_julian", - "_dt_to_julian", - "_julian_to_dt", - "_dt_to_stamp", - "_stamp_to_dt", - "_check_dt", - "_ReuseCycle", - "_arange_div", - "_hashable_ndarray", - "_custom_lru_cache", - ], - "mixin": [ - "SizeMixin", - "GetEpochsMixin", - "TimeMixin", - "ExtendedTimeMixin", - "_prepare_read_metadata", - "_prepare_write_metadata", - "_check_decim", - ], - "linalg": [ - "_svd_lwork", - "_repeated_svd", - "_sym_mat_pow", - "sqrtm_sym", - "eigh", - "_get_blas_funcs", - ], - "dataframe": [ - "_set_pandas_dtype", - "_scale_dataframe_data", - "_convert_times", - "_build_data_frame", - ], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/utils/__init__.pyi b/mne/utils/__init__.pyi new file mode 100644 index 00000000000..8dfc4a6bdc4 --- /dev/null +++ b/mne/utils/__init__.pyi @@ -0,0 +1,384 @@ +__all__ = [ + "ArgvSetter", + "Bunch", + "BunchConst", + "BunchConstNamed", + "ClosingStringIO", + "ExtendedTimeMixin", + "GetEpochsMixin", + "ProgressBar", + "SilenceStdout", + "SizeMixin", + "TimeMixin", + "_DefaultEventParser", + "_PCA", + "_ReuseCycle", + "_TempDir", + "_apply_scaling_array", + "_apply_scaling_cov", + "_arange_div", + "_array_equal_nan", + "_assert_no_instances", + "_auto_weakref", + "_build_data_frame", + "_cal_to_julian", + "_check_all_same_channel_names", + "_check_ch_locs", + "_check_channels_spatial_filter", + "_check_combine", + "_check_compensation_grade", + "_check_decim", + "_check_depth", + "_check_dict_keys", + "_check_dt", + "_check_edflib_installed", + "_check_eeglabio_installed", + "_check_event_id", + "_check_fname", + "_check_freesurfer_home", + "_check_head_radius", + "_check_if_nan", + "_check_info_inv", + "_check_integer_or_list", + "_check_on_missing", + "_check_one_ch_type", + "_check_option", + "_check_pandas_index_arguments", + "_check_pandas_installed", + "_check_preload", + "_check_pybv_installed", + "_check_pymatreader_installed", + "_check_qt_version", + "_check_range", + "_check_rank", + "_check_sphere", + "_check_src_normal", + "_check_stc_units", + "_check_subject", + "_check_time_format", + "_clean_names", + "_click_ch_name", + "_compute_row_norms", + "_convert_times", + "_custom_lru_cache", + "_doc_special_members", + "_dt_to_julian", + "_dt_to_stamp", + "_empty_hash", + "_ensure_events", + "_ensure_int", + "_explain_exception", + "_file_like", + "_freq_mask", + "_gen_events", + "_get_argvalues", + "_get_blas_funcs", + "_get_call_line", + "_get_extra_data_path", + "_get_inst_data", + "_get_numpy_libs", + "_get_root_dir", + "_get_stim_channel", + "_hashable_ndarray", + "_import_h5io_funcs", + "_import_h5py", + "_import_nibabel", + "_import_pymatreader_funcs", + "_is_numeric", + "_julian_to_cal", + "_julian_to_dt", + "_mask_to_onsets_offsets", + "_on_missing", + "_parse_verbose", + "_path_like", + "_pl", + "_prepare_read_metadata", + "_prepare_write_metadata", + "_raw_annot", + "_record_warnings", + "_reg_pinv", + "_reject_data_segments", + "_repeated_svd", + "_replace_md5", + "_require_version", + "_resource_path", + "_safe_input", + "_scale_dataframe_data", + "_scaled_array", + "_set_pandas_dtype", + "_soft_import", + "_stamp_to_dt", + "_suggest", + "_svd_lwork", + "_sym_mat_pow", + "_time_mask", + "_to_rgb", + "_undo_scaling_array", + "_undo_scaling_cov", + "_url_to_local_path", + "_validate_type", + "_verbose_safe_false", + "array_split_idx", + "assert_and_remove_boundary_annot", + "assert_dig_allclose", + "assert_meg_snr", + "assert_object_equal", + "assert_snr", + "assert_stcs_equal", + "buggy_mkl_svd", + "catch_logging", + "check_fname", + "check_random_state", + "check_version", + "compute_corr", + "copy_base_doc_to_subclass_doc", + "copy_doc", + "copy_function_doc_to_method_doc", + "create_slices", + "deprecated", + "deprecated_alias", + "eigh", + "fill_doc", + "filter_out_warnings", + "get_config", + "get_config_path", + "get_subjects_dir", + "grand_average", + "has_freesurfer", + "has_mne_c", + "hashfunc", + "int_like", + "legacy", + "linkcode_resolve", + "logger", + "object_diff", + "object_hash", + "object_size", + "open_docs", + "path_like", + "pformat", + "random_permutation", + "repr_html", + "requires_freesurfer", + "requires_good_network", + "requires_mne", + "requires_mne_mark", + "requires_openmeeg_mark", + "run_command_if_main", + "run_subprocess", + "running_subprocess", + "set_cache_dir", + "set_config", + "set_log_file", + "set_log_level", + "set_memmap_min_size", + "sizeof_fmt", + "split_list", + "sqrtm_sym", + "sum_squared", + "sys_info", + "use_log_level", + "verbose", + "warn", + "wrapped_stdout", +] +from ._bunch import Bunch, BunchConst, BunchConstNamed +from .check import ( + check_fname, + check_version, + check_random_state, + _check_fname, + _check_subject, + _check_pandas_installed, + _check_pandas_index_arguments, + _check_event_id, + _check_ch_locs, + _check_compensation_grade, + _check_if_nan, + _is_numeric, + _ensure_int, + _check_integer_or_list, + _check_preload, + _validate_type, + _check_range, + _check_info_inv, + _check_channels_spatial_filter, + _check_one_ch_type, + _check_rank, + _check_option, + _check_depth, + _check_combine, + _path_like, + _check_src_normal, + _check_stc_units, + _check_qt_version, + _check_sphere, + _check_time_format, + _check_freesurfer_home, + _suggest, + _require_version, + _on_missing, + _check_on_missing, + int_like, + _safe_input, + _check_all_same_channel_names, + path_like, + _ensure_events, + _check_eeglabio_installed, + _check_pybv_installed, + _check_edflib_installed, + _to_rgb, + _soft_import, + _check_dict_keys, + _check_pymatreader_installed, + _import_h5py, + _import_h5io_funcs, + _import_nibabel, + _import_pymatreader_funcs, + _check_head_radius, +) +from .config import ( + set_config, + get_config, + get_config_path, + set_cache_dir, + set_memmap_min_size, + get_subjects_dir, + _get_stim_channel, + sys_info, + _get_extra_data_path, + _get_root_dir, + _get_numpy_libs, +) +from .docs import ( + copy_function_doc_to_method_doc, + copy_doc, + linkcode_resolve, + open_docs, + deprecated, + fill_doc, + deprecated_alias, + legacy, + copy_base_doc_to_subclass_doc, + _doc_special_members, +) +from .fetching import _url_to_local_path +from ._logging import ( + verbose, + logger, + set_log_level, + set_log_file, + use_log_level, + catch_logging, + warn, + filter_out_warnings, + wrapped_stdout, + _get_call_line, + _record_warnings, + ClosingStringIO, + _verbose_safe_false, + _parse_verbose, +) +from .misc import ( + run_subprocess, + _pl, + _clean_names, + pformat, + _file_like, + _empty_hash, + _explain_exception, + _get_argvalues, + sizeof_fmt, + running_subprocess, + _DefaultEventParser, + _assert_no_instances, + _resource_path, + repr_html, + _auto_weakref, +) +from .progressbar import ProgressBar +from ._testing import ( + run_command_if_main, + requires_mne, + requires_good_network, + ArgvSetter, + SilenceStdout, + has_freesurfer, + has_mne_c, + _TempDir, + buggy_mkl_svd, + requires_freesurfer, + requires_mne_mark, + assert_object_equal, + assert_and_remove_boundary_annot, + _raw_annot, + assert_dig_allclose, + assert_meg_snr, + assert_snr, + assert_stcs_equal, + _click_ch_name, + requires_openmeeg_mark, +) +from .numerics import ( + hashfunc, + _compute_row_norms, + _reg_pinv, + random_permutation, + _reject_data_segments, + compute_corr, + _get_inst_data, + array_split_idx, + sum_squared, + split_list, + _gen_events, + create_slices, + _time_mask, + _freq_mask, + grand_average, + object_diff, + object_hash, + object_size, + _apply_scaling_cov, + _undo_scaling_cov, + _apply_scaling_array, + _undo_scaling_array, + _scaled_array, + _replace_md5, + _PCA, + _mask_to_onsets_offsets, + _array_equal_nan, + _julian_to_cal, + _cal_to_julian, + _dt_to_julian, + _julian_to_dt, + _dt_to_stamp, + _stamp_to_dt, + _check_dt, + _ReuseCycle, + _arange_div, + _hashable_ndarray, + _custom_lru_cache, +) +from .mixin import ( + SizeMixin, + GetEpochsMixin, + TimeMixin, + ExtendedTimeMixin, + _prepare_read_metadata, + _prepare_write_metadata, + _check_decim, +) +from .linalg import ( + _svd_lwork, + _repeated_svd, + _sym_mat_pow, + sqrtm_sym, + eigh, + _get_blas_funcs, +) +from .dataframe import ( + _set_pandas_dtype, + _scale_dataframe_data, + _convert_times, + _build_data_frame, +) diff --git a/mne/viz/__init__.py b/mne/viz/__init__.py index 2ec36d48941..f2f295ccf0c 100644 --- a/mne/viz/__init__.py +++ b/mne/viz/__init__.py @@ -1,109 +1,4 @@ """Visualization routines.""" - import lazy_loader as lazy -__getattr__, __dir__, __all__ = lazy.attach( - __name__, - submodules=["backends", "_scraper", "ui_events"], - submod_attrs={ - "backends._abstract": ["Figure3D"], - "backends.renderer": [ - "set_3d_backend", - "get_3d_backend", - "use_3d_backend", - "set_3d_view", - "set_3d_title", - "create_3d_figure", - "close_3d_figure", - "close_all_3d_figures", - "get_brain_class", - ], - "circle": ["circular_layout", "plot_channel_labels_circle"], - "epochs": [ - "plot_drop_log", - "plot_epochs", - "plot_epochs_psd", - "plot_epochs_image", - ], - "evoked": [ - "plot_evoked", - "plot_evoked_image", - "plot_evoked_white", - "plot_snr_estimate", - "plot_evoked_topo", - "plot_evoked_joint", - "plot_compare_evokeds", - ], - "evoked_field": [ - "EvokedField", - ], - "ica": [ - "plot_ica_scores", - "plot_ica_sources", - "plot_ica_overlay", - "_plot_sources", - "plot_ica_properties", - ], - "misc": [ - "plot_cov", - "plot_csd", - "plot_bem", - "plot_events", - "plot_source_spectrogram", - "_get_presser", - "plot_dipole_amplitudes", - "plot_ideal_filter", - "plot_filter", - "adjust_axes", - "plot_chpi_snr", - ], - "montage": ["plot_montage"], - "raw": ["plot_raw", "plot_raw_psd", "plot_raw_psd_topo", "_RAW_CLIP_DEF"], - "topo": ["plot_topo_image_epochs", "iter_topography"], - "topomap": [ - "plot_evoked_topomap", - "plot_projs_topomap", - "plot_arrowmap", - "plot_ica_components", - "plot_tfr_topomap", - "plot_topomap", - "plot_epochs_psd_topomap", - "plot_layout", - "plot_bridged_electrodes", - "plot_ch_adjacency", - "plot_regression_weights", - ], - "utils": [ - "tight_layout", - "mne_analyze_colormap", - "compare_fiff", - "ClickableImage", - "add_background_image", - "plot_sensors", - "centers_to_edges", - "concatenate_images", - "_get_plot_ch_type", - ], - "_3d": [ - "plot_sparse_source_estimates", - "plot_source_estimates", - "plot_vector_source_estimates", - "plot_evoked_field", - "plot_dipole_locations", - "snapshot_brain_montage", - "plot_head_positions", - "plot_alignment", - "plot_brain_colorbar", - "plot_volume_source_estimates", - "link_brains", - "set_3d_options", - ], - "_brain": ["Brain"], - "_figure": [ - "get_browser_backend", - "set_browser_backend", - "use_browser_backend", - ], - "_proj": ["plot_projs_joint"], - }, -) +(__getattr__, __dir__, __all__) = lazy.attach_stub(__name__, __file__) diff --git a/mne/viz/__init__.pyi b/mne/viz/__init__.pyi new file mode 100644 index 00000000000..e73226b6909 --- /dev/null +++ b/mne/viz/__init__.pyi @@ -0,0 +1,178 @@ +__all__ = [ + "Brain", + "ClickableImage", + "EvokedField", + "Figure3D", + "_RAW_CLIP_DEF", + "_get_plot_ch_type", + "_get_presser", + "_plot_sources", + "_scraper", + "add_background_image", + "adjust_axes", + "backends", + "centers_to_edges", + "circular_layout", + "close_3d_figure", + "close_all_3d_figures", + "compare_fiff", + "concatenate_images", + "create_3d_figure", + "get_3d_backend", + "get_brain_class", + "get_browser_backend", + "iter_topography", + "link_brains", + "mne_analyze_colormap", + "plot_alignment", + "plot_arrowmap", + "plot_bem", + "plot_brain_colorbar", + "plot_bridged_electrodes", + "plot_ch_adjacency", + "plot_channel_labels_circle", + "plot_chpi_snr", + "plot_compare_evokeds", + "plot_cov", + "plot_csd", + "plot_dipole_amplitudes", + "plot_dipole_locations", + "plot_drop_log", + "plot_epochs", + "plot_epochs_image", + "plot_epochs_psd", + "plot_epochs_psd_topomap", + "plot_events", + "plot_evoked", + "plot_evoked_field", + "plot_evoked_image", + "plot_evoked_joint", + "plot_evoked_topo", + "plot_evoked_topomap", + "plot_evoked_white", + "plot_filter", + "plot_head_positions", + "plot_ica_components", + "plot_ica_overlay", + "plot_ica_properties", + "plot_ica_scores", + "plot_ica_sources", + "plot_ideal_filter", + "plot_layout", + "plot_montage", + "plot_projs_joint", + "plot_projs_topomap", + "plot_raw", + "plot_raw_psd", + "plot_raw_psd_topo", + "plot_regression_weights", + "plot_sensors", + "plot_snr_estimate", + "plot_source_estimates", + "plot_source_spectrogram", + "plot_sparse_source_estimates", + "plot_tfr_topomap", + "plot_topo_image_epochs", + "plot_topomap", + "plot_vector_source_estimates", + "plot_volume_source_estimates", + "set_3d_backend", + "set_3d_options", + "set_3d_title", + "set_3d_view", + "set_browser_backend", + "snapshot_brain_montage", + "tight_layout", + "ui_events", + "use_3d_backend", + "use_browser_backend", +] +from . import backends, _scraper, ui_events +from .backends._abstract import Figure3D +from .backends.renderer import ( + set_3d_backend, + get_3d_backend, + use_3d_backend, + set_3d_view, + set_3d_title, + create_3d_figure, + close_3d_figure, + close_all_3d_figures, + get_brain_class, +) +from .circle import circular_layout, plot_channel_labels_circle +from .epochs import plot_drop_log, plot_epochs, plot_epochs_psd, plot_epochs_image +from .evoked import ( + plot_evoked, + plot_evoked_image, + plot_evoked_white, + plot_snr_estimate, + plot_evoked_topo, + plot_evoked_joint, + plot_compare_evokeds, +) +from .evoked_field import EvokedField +from .ica import ( + plot_ica_scores, + plot_ica_sources, + plot_ica_overlay, + _plot_sources, + plot_ica_properties, +) +from .misc import ( + plot_cov, + plot_csd, + plot_bem, + plot_events, + plot_source_spectrogram, + _get_presser, + plot_dipole_amplitudes, + plot_ideal_filter, + plot_filter, + adjust_axes, + plot_chpi_snr, +) +from .montage import plot_montage +from .raw import plot_raw, plot_raw_psd, plot_raw_psd_topo, _RAW_CLIP_DEF +from .topo import plot_topo_image_epochs, iter_topography +from .topomap import ( + plot_evoked_topomap, + plot_projs_topomap, + plot_arrowmap, + plot_ica_components, + plot_tfr_topomap, + plot_topomap, + plot_epochs_psd_topomap, + plot_layout, + plot_bridged_electrodes, + plot_ch_adjacency, + plot_regression_weights, +) +from .utils import ( + tight_layout, + mne_analyze_colormap, + compare_fiff, + ClickableImage, + add_background_image, + plot_sensors, + centers_to_edges, + concatenate_images, + _get_plot_ch_type, +) +from ._3d import ( + plot_sparse_source_estimates, + plot_source_estimates, + plot_vector_source_estimates, + plot_evoked_field, + plot_dipole_locations, + snapshot_brain_montage, + plot_head_positions, + plot_alignment, + plot_brain_colorbar, + plot_volume_source_estimates, + link_brains, + set_3d_options, +) +from ._brain import Brain +from ._figure import get_browser_backend, set_browser_backend, use_browser_backend +from ._proj import plot_projs_joint diff --git a/tools/dev_reports/Makefile b/tools/dev/Makefile similarity index 100% rename from tools/dev_reports/Makefile rename to tools/dev/Makefile diff --git a/tools/dev_reports/check_steering_committee.py b/tools/dev/check_steering_committee.py similarity index 100% rename from tools/dev_reports/check_steering_committee.py rename to tools/dev/check_steering_committee.py diff --git a/tools/dev/generate_pyi_files.py b/tools/dev/generate_pyi_files.py new file mode 100644 index 00000000000..f7804e895e8 --- /dev/null +++ b/tools/dev/generate_pyi_files.py @@ -0,0 +1,76 @@ +import os +import sys +from importlib import import_module +from pathlib import Path + +import ast_comments as ast +import black +import mne + + +class RewriteAssign(ast.NodeTransformer): + """NodeTransformer to replace lazy attach with attach_stub.""" + + def visit_Assign(self, node): + """Replace lazy attach assignment with stub assignment.""" + if not hasattr(node.targets[0], "dims"): + return node + + ids = [name.id for name in node.targets[0].dims] + if ids == ["__getattr__", "__dir__", "__all__"]: + return ast.parse( + "__getattr__, __dir__, __all__ = lazy.attach_stub(__name__, __file__)\n" + ) + return node + + +pyi_mode = black.Mode(is_pyi=True) +root = Path(mne.__file__).parent +inits = root.rglob("__init__.py") + +for init in inits: + # skip init files that don't lazy load (e.g., tests) + code = init.read_text("utf-8") + if "import lazy_loader as lazy" not in code: + continue + # get the AST + tree = ast.parse(code) + nodes = [node for node in tree.body if isinstance(node, ast.Assign)] + assert len(nodes) == 1 + node = nodes[0] + keywords = node.value.keywords + # get submodules + import_lines = list() + assert keywords[0].arg == "submodules" + # for submod in keywords[0].value.elts: + # import_lines.append(f"import {submod.value}") + submods = [submod.value for submod in keywords[0].value.elts] + if len(submods): + import_lines.append(f"from . import {', '.join(submods)}") + # get attrs + assert keywords[1].arg == "submod_attrs" + _dict = keywords[1].value + for key, vals in zip(_dict.keys, _dict.values): + attrs = [attr.value for attr in vals.elts] + import_lines.append(f"from .{key.value} import {', '.join(attrs)}") + # format + import_lines = black.format_str("\n".join(import_lines), mode=pyi_mode) + # get __all__ + import_path = str(init.parent.relative_to(root.parent)).replace(os.sep, ".") + import_module(import_path) + _all = black.format_str( + f"__all__ = {repr(sys.modules[import_path].__all__)}\n", + mode=pyi_mode, + ) + # write __init__.pyi + outfile = init.with_suffix(".pyi") + with open(outfile, "w") as fid: + fid.write(_all) + fid.write(import_lines) + # rewrite __init__.py + new_tree = RewriteAssign().visit(tree) + new_tree = ast.fix_missing_locations(new_tree) + new_code = ast.unparse(new_tree) + formatted_code = black.format_str(new_code, mode=black.Mode()) + with open(init, "w") as fid: + fid.write(formatted_code) diff --git a/tools/dev_reports/unacknowledged-bug-reports.jq b/tools/dev/unacknowledged-bug-reports.jq similarity index 100% rename from tools/dev_reports/unacknowledged-bug-reports.jq rename to tools/dev/unacknowledged-bug-reports.jq