Example #1
0
def load_data(*args, **kwargs):
    """Loads the data and checks its validity."""
    # Merge the data.
    loaders = [pm.Loader(filename) for filename in args[0]]
    data = pm.Merger(*loaders)
    for mouse in sorted(data.getGroup()):
        print(mouse)

    # Update timeline.ini
    conf = cp.ConfigParser()
    conf.read("timeline/timeline.ini")
    conf["Phase 1"]["start"] = kwargs["start"]
    conf["Phase 1"]["end"] = kwargs["end"]
    with open(os.path.join("timeline/timeline.ini"), "w") as file:
        conf.write(file)

    # Read in period of analysis from timeline.ini.
    timeline = pm.Timeline("timeline/timeline.ini")
    start, end = timeline.getTimeBounds("Phase 1")

    # Check for any problems (indicated in the log) during the period of interest.
    data_validator = pm.DataValidator(pm.PresenceLogAnalyzer())
    validator_report = data_validator(data)
    no_presence_problems = pm.FailureInspector("Presence")
    if no_presence_problems(validator_report, (start, end)):
        pass
    else:
        print("Possible transponder problems")

    return data, start, end
Example #2
0
def load_data(*args, **kwargs):
    """This function loads the data and checks its validity."""

    import pymice as pm

    # Files relevent to Habituation 1 (hab1) period.
    dataFiles = [0 for x in range(len(args))]
    for i in range(0, len(args)):
        dataFiles[i] = args[i]

    # Merge the data.
    loaders = [pm.Loader(filename) for filename in dataFiles]
    data = pm.Merger(*loaders)

    print("Done loading data.")

    for mouse in sorted(data.getGroup()):
        print(mouse)
    print("Ignore Pump group, it is related to another experiment.")

    # Read in hab1 period from timeline.ini.
    timeline = pm.Timeline('../timeline/hab1.ini')
    start1, end1 = timeline.getTimeBounds(kwargs['phase1'])
    start2, end2 = timeline.getTimeBounds(kwargs['phase2'])
    print("%s:\t%s - %s" % (kwargs['phase1'], start1, end1))
    print("%s:\t%s - %s" % (kwargs['phase2'], start2, end2))

    # Check for any problems (indicated in the log) during the period of interest.
    dataValidator = pm.DataValidator(pm.PresenceLogAnalyzer())
    validatorReport = dataValidator(data)

    noPresenceProblems = pm.FailureInspector('Presence')

    if noPresenceProblems(validatorReport, (start1, end1)):
        if noPresenceProblems(validatorReport, (start2, end2)):
            print("Presences OK.")

    return data, start1, end1, start2, end2
Example #3
0
    for v in visits_corners:
        if v.Module == "PlaceLearning" and v.PlaceError == 0:
            assignedcorner = v.Corner
            return (assignedcorner)


###########################################################################################
#find and open the data, assign it a name
ending = '\*.zip'
msg, title = "Please select the folder containing your Place and Reversal learning data files", "Import PL/RL Data"
data = g.diropenbox(msg, title)
data = data + ending

PL_data = sorted(glob.glob(data), key=os.path.getmtime)
loaders = [pm.Loader(filename, getEnv=True) for filename in PL_data]
PL = pm.Merger(*loaders, getEnv=True)

msg, title = "Name your Data", "Name Data"
name = g.enterbox(msg, title)
excelname = name + ".xlsx"
writer = pd.ExcelWriter(excelname, engine='xlsxwriter')

#set up data frame
cols = ["Name", "Sex", "Group", "Phase", "Phase Cycle", "Avg NPs per Visit"]

df_Place = pd.DataFrame(columns=cols)

#Extract first phase of Place Learning for each half hour analysis
phases = get_phases(PL.getEnvironment())
phase_count = len(phases)
for group in PL.getGroup():