egrace479's picture
Add mimic groups (#6)
3264ec4 verified

Summary of Deduplication

We explored our downloaded images in notebooks/EDA-DL-0-3.ipynb, and established the following causes of duplication along with remedies:

  1. The "patch" record (record 3477891) which required alignment in notebooks/Data-gen-1-1.ipynb, resulting in metadata/Jiggins_Zenodo_Img_Master_3477891Patch.csv used for download, is a duplication of all listed records. Additionally, it introduced extra copies of 4 images with incorrect labels for their views (i.e., dorsal vs ventral).
  • Solution: This record will be removed.
  1. The remaining duplication (430 images x2) comes from 5 records: 4291095, 2813153, 5526257, 2553977, and 2552371.
  • Though there is nothing in their descriptions on Zenodo to indicate this overlap occurred, record 4291095 duplicated 415 images from record 2813153. 104 of these images had their view/side labels (dorsal vs ventral) updated to reflect an earlier mislabeling in record 2813153; these were all RAW copies of the images. All other metadata was consistent across records.
  • Solution: Copies of these images and their metadata will be retained from the newer record, record 4291095.
  • Record 5526257 has 10 images that were added twice. All their metadata is consistent, so we will just keep the first instance of each image.
  • Records 2553977 and 2552371 are both "Miscellaneous Heliconius wing photographs (2001-2019)" Parts 3 & 1, respectively. Record 2553977 has duplicated images with matching metadata, though 3 of the 4 images have different filenames (Image_name). It seems to have resulted from typos or not indicating cut, as they are all close-up crops of a single wing. From this perspective, the view labels (dorsal) don't seem appropriate when we have more fine-grained indicators such as "forewing dorsal".
    • Suggestion that the entries in this record with cut in the filename not be used for general classification unless this variety is desired. These also appear to be all the tif images, which are often ignored.
    • Record 2552371 has one image duplicated with two different CAMIDs assigned (different views as well). These will both be removed as the image has no indicator of the specimen ID in it. Note that these also were labeled Heliconius sp..
  1. Looking at images that were not duplicates, there are clearly still multiple images of the same specimen from the same perspective (eg., two dorsal images) that are also of the same file type (eg., both jpgs). Duplication was checked at the pixel level, so there is no guarantee that they are truly different images, but due to the scope of this collection (over 20 years), it does not seem unlikely that multiple images could have been taken of the same specimen.
  • Suggestion/Solution: When determining splits using this data, follow these steps:
    1. Ensure you are looking at only one view (eg., dorsal or ventral).
    2. Ensure you are only looking one file type (raw, jpg, or tif).
    3. Reduce to only unique CAMIDs.
    4. Generate splits as desired.
    5. Add images to splits based on matched CAMIDs if multiple views are desired (i.e., if a CAMID is present in the dorsal training, add the matching ventral image to the training set).
    6. Be sure to check only desired categories are included, such as excluding hybrids or cross types, or specimens not labeled to the level of classification.

Final deduplication following this process was completed in notebooks/Data-gen-1-2.ipynb.

Other Notes on Using this Data

Not all images are labeled with the same detail. For instance, there are images labeled to the subspecies and species levels, while some images are not labeled past genus (eg., Heliconius sp., Heliconius hybrid). If classifying to the subspecies level, be sure to only include images that have labels in the subspecies column, similarly, when doing species classification, don't include those not labeled past genus (exclude species labels <Genus> sp. and Heliconius hybrid).

The Taxonomic_Name column has been standardized to <Genus> <species> ssp. <subspecies> (where species and subspecies are available). If species label is unavailable, Taxonomic_Name and species columns are labeled <Genus> sp. or Heliconius hybrid.

Cross type specimens (those mixed in a lab to generate hybrids or back-crosses) are indicated by a non-null value in the Cross_Type column. Their subspecies column is written out in full indicating parentage (eg., (plesseni x malleti) x malleti), unlike in the Taxonomic_Name column, where they're standardized to match the formatting of other hybrids. Use the following code to filter back crosses and F2 hybrids if just F1s are desired:

import pandas as pd

df = pd.read_csv(MASTER_FILE_PATH, low_memory = False)

cross_types_rm = []
for ssp in list(df.loc[df["Cross_Type"].notna(), "subspecies"].unique()):
    if " x " in ssp:
        split_x = ssp.split(" x ")
        if len(split_x) > 2:
            cross_types_rm.append(ssp)

print(len(cross_types_rm)) 

non_bcross = df.loc[~df["subspecies"].isin(cross_types_rm)]