Skip to content

Commit

Permalink
Move config directory outside of package
Browse files Browse the repository at this point in the history
And rename it to dataset_config
  • Loading branch information
caiw committed Feb 23, 2024
1 parent 7ae9d87 commit ce9e386
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 13 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion invokers/invoker_create_trialwise_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# noinspection DuplicatedCode
def main():
config = load_config(str(Path(Path(__file__).parent.parent, "kymata", "config", "dataset4.yaml")))
config = load_config(str(Path(Path(__file__).parent.parent, "dataset_config", "dataset4.yaml")))

create_trialwise_data(
dataset_directory_name=config['dataset_directory_name'],
Expand Down
4 changes: 2 additions & 2 deletions invokers/invoker_estimate_noise_cov_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# noinspection DuplicatedCode
def main():
config = load_config(str(Path(Path(__file__).parent.parent, "kymata", "config", "dataset4.yaml")))
config = load_config(str(Path(Path(__file__).parent.parent, "dataset_config", "dataset4.yaml")))

if config['data_location'] == "local":
data_root_dir = str(Path(Path(__file__).parent.parent, "kymata-toolbox-data", "emeg_study_data")) + "/"
Expand All @@ -15,7 +15,7 @@ def main():
elif config['data_location'] == "cbu-local":
data_root_dir = '//cbsu/data/imaging/projects/cbu/kymata/data/'
else:
raise Exception("The 'data_location' parameter in the config file must be either 'cbu' or 'local' or 'cbu-local'.")
raise Exception("The 'data_location' parameter in the dataset_config file must be either 'cbu' or 'local' or 'cbu-local'.")

estimate_noise_cov( data_root_dir = data_root_dir,
emeg_machine_used_to_record_data = config['emeg_machine_used_to_record_data'],
Expand Down
4 changes: 2 additions & 2 deletions invokers/invoker_run_data_cleansing.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# noinspection DuplicatedCode
def main():
config = load_config(str(Path(Path(__file__).parent.parent, "kymata", "config", "dataset4.yaml")))
config = load_config(str(Path(Path(__file__).parent.parent, "dataset_config", "dataset4.yaml")))

if config['data_location'] == "local":
data_root_dir = str(Path(Path(__file__).parent.parent, "kymata-toolbox-data", "emeg_study_data")) + "/"
Expand All @@ -17,7 +17,7 @@ def main():
elif config['data_location'] == "cbu-local":
data_root_dir = '//cbsu/data/imaging/projects/cbu/kymata/data/'
else:
raise Exception("The 'data_location' parameter in the config file must be either 'cbu' or 'local' or 'cbu-local'.")
raise Exception("The 'data_location' parameter in the dataset_config file must be either 'cbu' or 'local' or 'cbu-local'.")

run_first_pass_cleansing_and_maxwell_filtering(
data_root_dir = data_root_dir,
Expand Down
4 changes: 2 additions & 2 deletions invokers/invoker_run_hexel_current_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# noinspection DuplicatedCode
def main():
config = load_config(str(Path(Path(__file__).parent.parent, "kymata", "config", "dataset4.yaml")))
config = load_config(str(Path(Path(__file__).parent.parent, "dataset_config", "dataset4.yaml")))

if config['data_location'] == "local":
data_root_dir = str(Path(Path(__file__).parent.parent, "kymata-toolbox-data", "emeg_study_data")) + "/"
Expand All @@ -17,7 +17,7 @@ def main():
elif config['data_location'] == "cbu-local":
data_root_dir = '//cbsu/data/imaging/projects/cbu/kymata/data/'
else:
raise Exception("The 'data_location' parameter in the config file must be either 'cbu' or 'local' or 'cbu-local'.")
raise Exception("The 'data_location' parameter in the dataset_config file must be either 'cbu' or 'local' or 'cbu-local'.")

# create_current_estimation_prerequisites(data_root_dir, config=config)

Expand Down
2 changes: 1 addition & 1 deletion invokers/run_gridsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def main():
args = parser.parse_args()

# TODO: use config for ppt lists etc
#config = load_config(str(Path(Path(__file__).parent.parent, "kymata", "config", "dataset4.yaml")))
#dataset_config = load_config(str(Path(Path(__file__).parent.parent, "dataset_config", "dataset4.yaml")))

participants = [
'pilot_01',
Expand Down
4 changes: 2 additions & 2 deletions kymata/io/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@


def load_config(config_location: str):
"""Load config parameters"""
"""Load dataset_config parameters"""
with open(config_location, "r") as stream:
return yaml.safe_load(stream)

def modify_param_config(config_location: str, key: str, value):
with open(config_location, 'r') as stream:
"""Load config parameter"""
"""Load dataset_config parameter"""
data = yaml.safe_load(stream)
data[key] = value
yaml.emitter.Emitter.process_tag = lambda self, *args, **kw: None
Expand Down
4 changes: 2 additions & 2 deletions kymata/preproc/data_cleansing.py
Original file line number Diff line number Diff line change
Expand Up @@ -674,10 +674,10 @@ def apply_automatic_bad_channel_detection(raw_fif_data: mne.io.Raw, machine_used
raw_check = raw_fif_data.copy()

fine_cal_file = Path(Path(__file__).parent.parent,
'config', 'cbu_specific_files',
'kymata-toolbox-data', 'cbu_specific_files',
'sss_cal' + machine_used + '.dat')
crosstalk_file = Path(Path(__file__).parent.parent,
'config', 'cbu_specific_files',
'kymata-toolbox-data', 'cbu_specific_files',
'ct_sparse' + machine_used + '.fif')

auto_noisy_chs, auto_flat_chs, auto_scores = mne.preprocessing.find_bad_channels_maxwell(
Expand Down
2 changes: 1 addition & 1 deletion kymata/preproc/hexel_current_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def create_forward_model_and_inverse_solution(data_root_dir, config: dict):
elif config['eeg']:
mne.write_forward_solution(Path(intrim_preprocessing_directory_name, "4_hexel_current_reconstruction","forward_sol_files", participant + '-fwd-eegonly.fif'), fwd)
else:
raise Exception('eeg and meg in the config file cannot be both False')
raise Exception('eeg and meg in the dataset_config file cannot be both False')

# Compute inverse operator

Expand Down

0 comments on commit ce9e386

Please sign in to comment.