Exemple #1
0
subdir_list = []
for der in der_names:
    temp_name = subdir_name + "/" + der
    subdir_list.append(temp_name)

init_kwargs = {
    "input_directory": input_dir,
    "save_directory": save_dir,
    "subdir_name": subdir_name,
    "func": (prep, "read_file_to_df"),
    "search_suffix": ".csv",
    "readfile": True,
    "index_col": [0, 1, 2],
    "header": [0]
}
delta_create_object = prep.SaveObjectPipeline(**init_kwargs)

delta_process_kwargs = {
    "function": (prep, "create_df_for_single_band"),
    "savecsv": False,
    "name_of_band": ["Delta"],
    "range_to_sum": ("0.50Hz", "4.00Hz")
}
delta_create_object.process_file(**delta_process_kwargs)

for der_no, subdir in enumerate(subdir_list):
    init_kwargs["subdir_name"] = subdir
    cumsum_plot_object = prep.SaveObjectPipeline(**init_kwargs)
    process_kwargs = {
        "function": (prep, "create_stage_df"),
        "savecsv": False,
input_dir = pathlib.Path("/Users/angusfisk/Documents/01_PhD_files/01_projects"
                         "/P3_LLEEG_Chapter3/01_data_files/07_clean_fft_files")
save_dir = input_dir.parents[1] / "03_analysis_outputs"
subdir_name = "01_delta_hypnograms"

init_kwargs = {
    "input_directory": input_dir,
    "save_directory": save_dir,
    "subdir_name": subdir_name,
    "func": (prep, "read_file_to_df"),
    "search_suffix": ".csv",
    "readfile": True,
    "index_col": [0, 1, 2],
    "header": [0]
}
hypnogram_object = prep.SaveObjectPipeline(**init_kwargs)

process_kwargs = {"function": (prep, "_sep_by_top_index"), "savecsv": False}
hypnogram_object.process_file(**process_kwargs)

plot_kwargs = {
    "function": (plot, "plot_hypnogram_from_list"),
    "remove_col": False,
    "data_list": hypnogram_object.processed_list,
    "showfig": False,
    "savefig": True,
    "figsize": (10, 10),
    "name_of_band": ["Delta"],
    "range_to_sum": ("0.50Hz", "4.00Hz"),
    "level_of_index": 0,
    "label_col": -1,
save_dir = input_dir.parents[1]
subdir_name = "01_data_files/08_stage_csv"
plot_subdir_name = "03_analysis_outputs/02_cumulative_plots/01_cumulative_sleep"
plot_subdir_path = prep.create_subdir(save_dir, plot_subdir_name)

init_kwargs = {
    "input_directory": input_dir,
    "save_directory": save_dir,
    "subdir_name": subdir_name,
    "func": (prep, "read_file_to_df"),
    "search_suffix": ".csv",
    "readfile": True,
    "index_col": [0, 1, 2],
    "header": [0]
}
cumulative_sleep_object = prep.SaveObjectPipeline(**init_kwargs)

process_kwargs = {
    "function": (prep, "create_stage_df"),
    "savecsv": True,
}
cumulative_sleep_object.process_file(**process_kwargs)

plot_kwargs = {
    "function": (plot, "plot_cumulative_from_stage_df"),
    "data_list": cumulative_sleep_object.processed_list,
    "remove_col": False,
    "subdir_path": plot_subdir_path,
    "stages": ["NR", "R", "NR1", "R1"],
    "base_freq": "4S",
    "target_freq": "1H",
Exemple #4
0
import pathlib
import sys
sys.path.insert(0, "/Users/angusfisk/Documents/01_PhD_files/07_python_package/"
                "sleepPy")
import sleepPy.preprocessing as prep

input_dir = pathlib.Path("/Users/angusfisk/Documents/01_PhD_files/"
                               "01_projects/P3_LLEEG_Chapter3/01_data_files/"
                               "06_fft_files")
                              
save_dir = input_dir.parent
subdir_name = "07_clean_fft_files"

clean_object = prep.SaveObjectPipeline(input_directory=input_dir,
                                      save_directory=save_dir,
                                      search_suffix=".txt",
                                      readfile=False,
                                      subdir_name=subdir_name)

animal_file_list = prep.create_dict_of_animal_lists(clean_object.file_list,
                                                    input_dir,
                                                    anim_range=(0,3))
                                                    
kwargs = {
    "save_suffix_file": "_clean.csv",
    "savecsv": True,
    "function": (prep, "single_df_for_animal"),
    "object_list": animal_file_list.values(),
    "file_list": animal_file_list.keys(),
    "header": 17,
    "derivation_list": ["fro", "occ", "foc"],
Exemple #5
0
for stage in stage_list:
    for der in der_names:
        temp_name = subdir_name + "/" + stage + "/" + der
        subdir_list.append(temp_name)

init_kwargs = {
    "input_directory": input_dir,
    "save_directory": save_dir,
    "subdir_name": subdir_name,
    "func": (prep, "read_file_to_df"),
    "search_suffix": ".csv",
    "readfile": True,
    "index_col": [0, 1, 2],
    "header": [0]
}
spectrum_object = prep.SaveObjectPipeline(**init_kwargs)

process_kwargs = {
    "function": (prep, "_get_spectrum_between_times"),
    "savecsv": False,
    "stage": ["W"],
    "stage_col": "Stage",
    "time_start": "12:00:00",
    "time_end": "00:00:00",
}
spectrum_object.process_file(**process_kwargs)

spectrum_list = prep._get_spectrum_between_times(df, **kwargs)

spectrum_df = spectrum_list[0]