-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchildloc_pri Check Typo & ID.rb
More file actions
99 lines (79 loc) · 3.35 KB
/
childloc_pri Check Typo & ID.rb
File metadata and controls
99 lines (79 loc) · 3.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
### Typo check for pri child locomotion coding.
## Parameters
map_child = { 'childloc' => { 'loc_lfmdr' => %w(l f m d r .) } }
cell_thresh = 3000 #threshold for between coded cells
#list of all "codes" within ID column
id_map = {'loc_id_child' => %w[lab_id childloc_coder childloc_date childloc_mins]}
#list of all lab_id possible
lab_id_list = %w[BOSTU_1 BRKLN_1 CSUFL_1 CMUNI_2 CHOPH_1 CORNL_1 CUNYS_1 GEORG_1
HRVDU_1 INDNA_1 LEHUN_1 MICHS_1 MICHS_2 MTALL_1 NYUNI_1 NYUNI_2 OHIOS_1 PENNS_2
PENNS_4 PENNS_5 PLAYT_1 PRINU_1 PURDU_1 PURDU_2 RUTGU_1 STANF_1 TEXAM_1 TULNU_1 UCDAV_1
UCLOS_1 UCMER_1 UCRIV_1 UCRIV_2 UCSCR_1 UCONN_1 UCONN_2 UGEOR_1 UHOUS_1 UMIAM_1
UOREG_1 UPITT_1 UPITT_2 USCAL_1 UTAUS_1 UTAUS_2 UTORS_1 UWATR_1 VBLTU_1 VBLTU_2 VCOMU_1 WILLC_1]
## Body
require 'Datavyu_API.rb'
#Check child column
puts "Wrong Codes:"
check_valid_codes3(map_child)
puts
# Do additional checks on timestamps
puts "Wrong Duration:"
childloc=getColumn("childloc")
prevcell=nil #ref to previous col
# Loop over all the movement cells
childloc.cells.each do |childloccell|
ordinal = childloccell.ordinal.to_i
onset = childloccell.onset.to_i
offset = childloccell.offset.to_i
if onset >= offset
puts("CELL #{ordinal} ONSET >= OFFSET")
end
if offset-onset<34
puts("CELL #{ordinal} DURATION < 1 FRAME")
end
if (!prevcell.nil? && onset < prevcell.offset.to_i)
puts("CELL #{ordinal} ONSET < PREVIOUS OFFSET")
end
# This check identifies consecutive loc cells that are less than l_cell_thresh apart
l_cell_thresh = 1000 # minimum number of ms between consecutive walk cells
if (!prevcell.nil? && prevcell.loc_lfmdr==childloccell.loc_lfmdr &&
(childloccell.onset-prevcell.offset).abs<l_cell_thresh)
puts("CELLS #{prevcell.ordinal} and #{childloccell.ordinal} are walking bouts with less than #{l_cell_thresh}ms interval")
end
missing_cell_thresh = 1000 # minimum number of ms that a missing cell can last
if childloccell.loc_lfmdr == "." and offset-onset<missing_cell_thresh
puts ("CELL #{ordinal} IS MISSING BUT <1s IN DURATION")
end
prevcell = childloccell
end
puts
#Check for typo in the lab_id under loc_id_child
#Check to see if it matches one of the labs listed above
puts "Wrong ID entry/format:"
id_col_list = id_map.keys
id_col_list.each do |col_name|
code_list = id_map[col_name]
col = get_column(col_name)
code_list.each do |code_name|
col.cells.each do |c|
if code_name == 'lab_id'
unless lab_id_list.include?( c.get_code(code_name) )
puts "#{col_name} contains a typo for code <#{code_name}>"
end
elsif code_name.include?('coder')
if c.get_code(code_name).match(/^(\A[a-zA-Z]*\z)$/).nil?
puts "#{col_name} contain a typo for code <#{code_name}>"
end
elsif code_name.include?('date')
if c.get_code(code_name).match(/^(?:(0?2)\/([12][0-9]|0?[1-9])|(0?[469]|11)\/(30|[12][0-9]|0?[1-9])|(0?[13578]|1[02])\/(3[01]|[12][0-9]|0?[1-9]))\/((?:[0-9]{2})?[0-9]{2})$/).nil?
puts "#{col_name} contain a typo for code <#{code_name}>"
end
elsif code_name.include?('mins')
if c.get_code(code_name).match(/^\d{3}$/).nil?
puts "#{col_name} contain a typo for code <#{code_name}>"
puts
end
end
end
end
end