EOGrady21 / vprr

Video Plankton Recorder Data Processing
https://eogrady21.github.io/vprr/
Other
2 stars 1 forks source link

"Empty" reclassification files created by vpr_manual_classification() still have 1 line with no text #39

Closed kevinsorochan closed 11 months ago

kevinsorochan commented 1 year ago

Describe the bug "Empty" reclassification files created by vpr_manual_classification() still have 1 line. This causes problems when running vpr_autoid_create() which expects the files to have a line number of zero.

To Reproduce Reproducible code example of the bug, with output if appropriate.

...

Expected behavior

vpr_autoid_create() expects the empty reclassification file to have zero lines

Screenshots If applicable, add screenshots to help explain your problem.

Session Info: [output from running sessionInfo()]

Additional context Add any other context about the problem here.

kevinsorochan commented 1 year ago

I was able to make a quick but not ideal fix in vpr_autoid_create() using:

if(unique(mis_roi) == "") {

mis_roi <- mis_roi[-c(1)]

}
EOGrady21 commented 1 year ago

The empty files likely just have one '\n' (a new empty line separator) due to the way the file is written cat(misclassified, sep = '\n')

I would suggest fixing this on the vpr_auotid_read() end of things. Although this issue is avoided if empty files are deleted as in the original workflow.

To fix in vpr_autoid_read, add a check for 'empty' files before reading them in. (line 786 in EC_functions.R)

for(i in 1:length(file_list_aid)) {

    data_tmp <- read.table(file = file_list_aid[i], stringsAsFactors = FALSE, col.names = col_names)
    data_tmp$roi <- unlist(vpr_roi(data_tmp$roi))
# Add in suggested check

suggested (pseudocode) check: if( data_tmp$roi[1] == ''){ skip_file[i] <- TRUE }

EOGrady21 commented 11 months ago

This has been resolved through other issues