Пример #1
0
nr_patterns = 1
df2 = pd.DataFrame()

for i_s, (participant, exp) in enumerate(zip(participants, experiments)):

    # load electrode positions
    participant_id = "%s_%s" % (participant, exp)
    raw = mne.io.read_raw_fif("../working/%s_raw.fif" % participant_id)
    raw.crop(0, 1)
    raw.load_data()
    raw.pick_types(ecog=True)
    raw = helper.reject_channels(raw, participant, exp)

    # load patterns for all peak frequencies
    peaks = helper.get_participant_peaks(participant, exp)

    for i_p, peak in enumerate(peaks):
        patterns, filters = helper.load_ssd(participant_id, peak)

        for idx in range(nr_patterns):
            pattern = patterns[:, idx]
            xyz = np.array([ich["loc"][:3] for ich in raw.info["chs"]])
            distance = squareform(pdist(xyz, "cityblock"))

            # find maximum value & select distance to maximum
            i_max = np.argmax(np.abs(pattern))
            dist_to_max = distance[i_max]

            # normalize pattern and find maxmium coefficient
            norm_pattern = np.abs(pattern / pattern[i_max])
participants = df.participant
experiments = df.experiment
df = df.set_index("participant")

results_dir = "../results/ssd/"
os.makedirs(results_dir, exist_ok=True)

for participant, experiment in list(zip(participants, experiments)):

    participant_id = "%s_%s" % (participant, experiment)
    print(participant_id)

    # get individual peaks
    peaks, bin_width1 = helper.get_participant_peaks(participant,
                                                     experiment,
                                                     return_width=True)

    # load raw-file
    file_name = "../working/%s_raw.fif" % participant_id
    raw = mne.io.read_raw_fif(file_name, preload=True)
    raw.pick_types(ecog=True)
    raw = helper.reject_channels(raw, participant, experiment)

    for i_peak, peak in enumerate(peaks):

        file_name = "%s/ssd_%s_peak_%.2f.npy" % (
            results_dir,
            participant_id,
            peak,
        )