Page MenuHomec4science

makeparam.py
No OneTemporary

File Metadata

Created
Fri, Apr 19, 02:12

makeparam.py

import json
from functions import get_biosemi_to_1020_mapping
'''
'methods': imcoh, pli, coh, plv, etc. Any method available
for mne.connectivity.spectral_connectivity()
'electrode_subset': A list of electrodes: ['A1', 'A2'] or
a pre-defined set of '32el10-20' or '64el10-20'
'select_x_best_electrodes': int or 'All'. If int is given, it will select the most statistically
significant set of the corresponding 'electrode_subset' (see above).
'change_el_labels': change electrode labels to 10-20 standard
'frequency_band': A bandwidth (pair of [fmin, fmax]) in which connectivity will be computed
'tmin_tmax': time around the stimulus (pair of [tmin, tmax])in seconds. If None,, [tmin, tmax] = [-0.2, 0.5]
'CSD_parameters': None or a pair of [stiffnes, lambda^2]: stiffness: 2-5, lambda^2: 0-10e-5
'conditions': 'responder' and/or 'proposer'
'subjects': list of subjects
'add_label': additional label
methods, electrode_subset, select_x_best_electrodes, CSD_parameters are mutli-loop.
subjects and add_label are fixed for all loops (1 value)
'''
filename = "npm_8-13Hz_0.7s_P.json"
# filename = "npm_8-13Hz_0.7s_R.json"
# filename = "npm_14-30Hz_0.7s_P.json"
# filename = "npm_14-30Hz_0.7s_R.json"
param_dict = {'methods': ['imcoh'], 'conditions': ['proposer'],
'frequency_band': [[8, 13]], 'electrode_subset': ['32el10-20'],
'select_x_best_electrodes': ["All"],
# int or 'All'. If int is given, it will select the most statistically
# significant set of the corresponding 'electrode_subset' (see above).
'change_el_labels': True,
'tmin_tmax': [[-2.25, -1.55], [-1.55, -0.85], [-0.7, 0.0], [-0.35, 0.35],
[0.0, 0.7], [0.85, 1.55], [1.55, 2.25]],
'CSD_parameters': [[3, 0.001]], # stiffness 2-5, lambda^2 0-10e-5
'datapath': "/mnt/data/NoCSD/",
'subjects': ['000', '007', '008', '009', '010', '011', '012', '013', '014',
'015', '016', '017', '018', '020', '021', '023', '025', '027',
'028', '029', '030', '031', '032', '034', '101', '102', '106',
'109', '110', '111', '112', '113', '114', '115', '116', '117',
'121', '124', '125', '126', '127', '128', '199'],
'add_label': "", 'result_dir': "/mnt/data/conn_results/results/"}
while len(param_dict['electrode_subset']) > len(
param_dict['select_x_best_electrodes']):
param_dict['select_x_best_electrodes'].append('All')
for i, sel_ch in enumerate(param_dict['electrode_subset']):
if sel_ch == 'All':
param_dict['electrode_subset'][i] = ['A1', 'A2', 'A3', 'A4', 'A5', 'A6',
'A7', 'A8', 'A9', 'A10', 'A11',
'A12', 'A13', 'A14', 'A15', 'A16',
'A17', 'A18', 'A19', 'A20', 'A21',
'A22', 'A23', 'A24', 'A25', 'A26',
'A27', 'A28', 'A29', 'A30', 'A31',
'A32', 'B1', 'B2', 'B3', 'B4',
'B5', 'B6', 'B7', 'B8', 'B9',
'B10', 'B11', 'B12', 'B13', 'B14',
'B15', 'B16', 'B17', 'B18', 'B19',
'B20', 'B21', 'B22', 'B23', 'B24',
'B25', 'B26', 'B27', 'B28', 'B29',
'B30', 'B31', 'B32', 'C1', 'C2',
'C3', 'C4', 'C5', 'C6', 'C7', 'C8',
'C9', 'C10', 'C11', 'C12', 'C13',
'C14', 'C15', 'C16', 'C17', 'C18',
'C19', 'C20', 'C21', 'C22', 'C23',
'C24', 'C25', 'C26', 'C27', 'C28',
'C29', 'C30', 'C31', 'C32', 'D1',
'D2', 'D3', 'D4', 'D5', 'D6', 'D7',
'D8', 'D9', 'D10', 'D11', 'D12',
'D13', 'D14', 'D15', 'D16', 'D17',
'D18', 'D19', 'D20', 'D21', 'D22',
'D23', 'D24', 'D25', 'D26', 'D27',
'D28', 'D29', 'D30', 'D31', 'D32']
elif sel_ch == '32el10-20':
electrode_mapping = get_biosemi_to_1020_mapping(32)
param_dict['electrode_subset'][i] = list(electrode_mapping.keys())
elif sel_ch == '64el10-20':
electrode_mapping = get_biosemi_to_1020_mapping(64)
param_dict['electrode_subset'][i] = list(electrode_mapping.keys())
else:
raise ValueError(
"Wrong channel selection parameter: should be a list of channel labels or 'All'")
if param_dict['datapath'][-1] is not "/":
param_dict['datapath'] += "/"
if param_dict['result_dir'][-1] is not "/":
param_dict['result_dir'] += "/"
json_dict = json.dumps(param_dict)
f = open(filename, "w")
f.write(json_dict)
f.close()
print(param_dict)

Event Timeline