-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchildobj_pri Check Typo & ID.rb
More file actions
87 lines (74 loc) · 3.01 KB
/
childobj_pri Check Typo & ID.rb
File metadata and controls
87 lines (74 loc) · 3.01 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
### Typo check for pri child object coding.
## Parameters
map_child = { 'childobj' => { 'obj_o' => %w(o .) } }
cell_thresh = 3000 #threshold for between coded cells
#list of all "codes" within ID column
id_map = {'obj_id_child' => %w[lab_id childobj_coder childobj_date childobj_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 UTAUS_1 UTAUS_2 UTORS_1 UWATR_1 VBLTU_1 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:"
child_code=getColumn("childobj")
prevcell=nil #ref to previous col
child_code.cells.each do |child_code_cell|
ordinal = child_code_cell.ordinal.to_i
onset = child_code_cell.onset
offset = child_code_cell.offset
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
if (!prevcell.nil? && child_code_cell.obj_o=='o' &&
prevcell.obj_o==child_code_cell.obj_o &&
(child_code_cell.onset-prevcell.offset).abs<cell_thresh)
puts("CELLS #{prevcell.ordinal} and #{child_code_cell.ordinal} are objects with less than #{cell_thresh}ms interval")
end
prevcell=child_code_cell
end
puts
#Check for typo in the lab_id under obj_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