示例#1
0
def main():

    (raw_data_path, intermediate_data_path,
    processed_data_path, figure_path) = cf.path_config()

    (unique_subjects, unique_sessions, unique_reward_codes) = md.extract_subjects_sessions(raw_data_path,
    reward_task=1)

    start_time = time.time()

    trial_end = 2000

    for subj_id in unique_subjects:
        for session_n in unique_sessions:


            print('z-scoring baseline corrected & lowpass filtered data for subject {}'.format(subj_id) +
            ' session {}'.format(session_n))


            _, _, reward_code = ep.find_data_files(subj_id=subj_id,
            session_n=session_n, reward_task=1, lum_task=0,
            raw_data_path=raw_data_path)


            reward_samples = ep.read_hdf5('samples', subj_id, session_n,
            processed_data_path, reward_code=reward_code, id_str='corr')
            reward_messages = ep.read_hdf5('messages', subj_id, session_n,
            processed_data_path, reward_code=reward_code, id_str='corr')
            reward_events = ep.read_hdf5('events', subj_id, session_n,
            processed_data_path, reward_code=reward_code, id_str='corr')


            reward_samples = z.zscore(reward_samples)

            plotting_reward_samples = reward_samples.loc[reward_samples.trial_sample <= trial_end]

            ## TODO: get reasonable y limits for all data within a subject and use that for plotting

            fig,figname = vz.visualize(plotting_reward_samples.trial_sample,
            plotting_reward_samples.z_pupil_diameter,
            subj_id, session_n, reward_code, id_str='zscored')

            vz.save(fig, figname)

            hdf = ep.save_hdf5(reward_samples, reward_events, reward_messages,
            subj_id, session_n, processed_data_path,
            reward_code=reward_code, id_str='zscored')
            print('z-scored data saved')



        end_time = time.time()

        time_elapsed = end_time - start_time
        print('time elapsed: ', time_elapsed)
示例#2
0
def main():

    (raw_data_path, intermediate_data_path, processed_data_path,
     figure_path) = cf.path_config()

    (unique_subjects, unique_sessions,
     unique_reward_codes) = md.extract_subjects_sessions(raw_data_path,
                                                         reward_task=1)

    start_time = time.time()

    for subj_id in unique_subjects:
        for session_n in unique_sessions:

            print('bandpass filtering data for subject {}'.format(subj_id) +
                  ' session {}'.format(session_n))

            _, _, reward_code = ep.find_data_files(subj_id=subj_id,
                                                   session_n=session_n,
                                                   reward_task=1,
                                                   lum_task=0,
                                                   raw_data_path=raw_data_path)

            reward_samples = ep.read_hdf5('samples',
                                          subj_id,
                                          session_n,
                                          processed_data_path,
                                          reward_code=reward_code,
                                          id_str='clean')
            reward_messages = ep.read_hdf5('messages',
                                           subj_id,
                                           session_n,
                                           processed_data_path,
                                           reward_code=reward_code,
                                           id_str='clean')
            reward_events = ep.read_hdf5('events',
                                         subj_id,
                                         session_n,
                                         processed_data_path,
                                         reward_code=reward_code,
                                         id_str='clean')

            reward_samples = bp.high_bandpass_filter(reward_samples)
            reward_samples = bp.low_bandpass_filter(reward_samples)

            lp_fig, lp_figname = vz.visualize(
                reward_samples.trial_sample,
                reward_samples.lowpass_pupil_diameter,
                subj_id,
                session_n,
                reward_code,
                id_str='lowpass')
            vz.save(lp_fig, lp_figname)
            hp_fig, hp_figname = vz.visualize(
                reward_samples.trial_sample,
                reward_samples.highpass_pupil_diameter,
                subj_id,
                session_n,
                reward_code,
                id_str='highpass')
            vz.save(hp_fig, hp_figname)

            hdf = ep.save_hdf5(reward_samples,
                               reward_events,
                               reward_messages,
                               subj_id,
                               session_n,
                               processed_data_path,
                               reward_code=reward_code,
                               id_str='bandpass')

    end_time = time.time()

    time_elapsed = end_time - start_time
    print('time elapsed: ', time_elapsed)