# Get any chopped video folders that already exist 
    existingDir = [file for file in allFiles if 'cut' in file]

    # Start analyzing by video
    for vid in allVids:

        filename = vid.split('.')
        filename = filename[0]

        # If the video has a csv file associated with it and was not previously cut
        if (filename + '.csv' in csvFiles) and (filename + '_cut' not in existingDir):
            
            print(filename,end='\n')
            
            # Read in the csv file
            csv = setDLCFunc.readfile(filename+'.csv')

            vidNum=0

            for times in csv:

                vidNum += 1

                if vidNum < 10:
                    indexVar = '0'+str(vidNum)
                else:
                    indexVar = str(vidNum)
                
                # Get start and end times
                times = times.split(',')
Beispiel #2
0
@author: kkrista
"""

import cv2
import os
import numpy as np
import setDLCFunc

locVidDir = '/media/kkrista/KRISTAEHD/DLCSR/leftPaw/'
docVidDir = '/opt/usb/DLCSR/leftPaw/'
cropParamDir = '/home/kkrista/Documents/leftPP_Left-Krista-2019-01-24/cropParam.txt'
trainFcsv = '/home/kkrista/Documents/leftPP_Left-Krista-2019-01-24/trainFiles.csv'
trainCropParam = '/home/kkrista/Documents/leftPP_Left-Krista-2019-01-24/trainCropParam.txt'

f = setDLCFunc.readfile(cropParamDir)
ff = setDLCFunc.readfile(trainFcsv)

writeIt = open(cropParamDir, 'w')
writeConfigCrop = open(trainCropParam, 'w')

train = []
g = []
h = []
origVids = []
configCrop = []
a = []
compName = []

cc = 0
while cc < len(ff):
Beispiel #3
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 10 15:16:49 2019

@author: kkrista
"""

import deeplabcut
import os
os.chdir('/home/kkrista/Documents/Script/PythonScripts/')
from setDLCFunc import readfile

config_path='/home/kkrista/Documents/rightPP_Center-Krista-2019-02-09/config.yaml'
crops=readfile('/home/kkrista/Documents/rightPP_Center-Krista-2019-02-09/cropParameters.txt')
vids = os.listdir('/opt/usb/DLCSR/rightPaw/')
allVids=['']*len(vids)
for ii in range(len(vids)):
    allVids[ii]='/opt/usb/DLCSR/rightPaw/'+vids[ii]


    
for ii in range(len(allVids)):
    if '710_20181126_01' in allVids[ii]:                                                               
        ind=crops.index(allVids[ii])
        params=crops[ind+1].split(', ')                                                   
	    cfg=deeplabcut.utils.auxiliaryfunctions.read_config(config_path)
        cfg['cropping']=true
	    cfg['x1']=int(params[0])
	    cfg['x2']=int(params[1])
	    cfg['y1']=int(params[2])
#dirToAnalyze = '/media/kkrista/KRISTAEHD/DLCSR/20190712/'

##

# First, obtain subject directories that need to be analyzed
subjDirs = os.listdir(dirToAnalyze)
subjs = [item.strip('et') for item in subjDirs]

# Loop through subjects
for subj in subjs:
    
    [pawPref, nonPrefPaw] = animalInfo.pawPref(subj)
    boxNum = animalInfo.boxID(subj)
    
    # Read the csv files needed for cropping
    directView_allCrops = setDLCFunc.readfile(cropParamsDir + 'CC' + boxNum + '_directCrops.csv')
    mirrorView_allCrops = setDLCFunc.readfile(cropParamsDir + 'CC' + boxNum + '_' + nonPrefPaw + 'Crops.csv')
    
    # Find the configuration files
    allDLCNets = os.listdir(DLCDir + pawPref + 'PP/')
    directNet = [item for item in allDLCNets if 'Center' in item]
    mirrorNet = [item for item in allDLCNets if nonPrefPaw[1:] in item.strip(pawPref + 'PP')]
    directConfig = DLCDir + pawPref + 'PP/' + directNet[0] + '/config.yaml'
    mirrorConfig = DLCDir + pawPref + 'PP/' + mirrorNet[0] + '/config.yaml'
    
    # Get all training days
    trainDayDirList = os.listdir(dirToAnalyze + 'et' + subj + '/Training/')
    trainDayDirList = [dirToAnalyze + 'et' + subj + '/Training/' + item for item in trainDayDirList if os.path.isdir(dirToAnalyze + 'et' + subj + '/Training/'+ item)]
    
    for day in trainDayDirList:
        
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 25 12:19:36 2019

@author: kkrista
"""

import setDLCFunc

setDLCFunc.readfile(wrkDir + "/config.yaml")