{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import numpy as np" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We explored the error file in `EDA-DL-0-1.ipynb` and saved a CSV of the failed download records, as it was not clear how we could potentially find those images from their Zenodo records (they didn't seem to be present in the records whose metadata listed them). There seem to be only 23 specimens that were not otherwise represented in our download.\n", "\n", "## Explore Downloaded Images\n", "\n", "We'll do an inner merge on the master file and checksums to get a master downloadable file, which will be further reduced to just unique images." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(42143, 3)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "checksums = pd.read_csv(\"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_checksums.csv\", low_memory=False)\n", "checksums.shape" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "filepath 42143\n", "filename 42143\n", "md5 36212\n", "dtype: int64" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "checksums.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Difference between these is the number of unique Image names among the duplicated images. " ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(44809, 28)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master = pd.read_csv(\"../metadata/Jiggins_Zenodo_Img_Master_3477891Patch.csv\", low_memory = False)\n", "master.shape" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "`filename` in `checksums` is `_`, so we'll create such a `filename` column in `master` to merge the two DataFrames on." ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 11991\n", "X 44809\n", "Image_name 36281\n", "View 7\n", "zenodo_name 33\n", "zenodo_link 30\n", "Sequence 10905\n", "Taxonomic_Name 366\n", "Locality 645\n", "Sample_accession 1559\n", "Collected_by 12\n", "Other_ID 3081\n", "Date 807\n", "Dataset 8\n", "Store 137\n", "Brood 224\n", "Death_Date 81\n", "Cross_Type 30\n", "Stage 1\n", "Sex 3\n", "Unit_Type 4\n", "file_type 3\n", "record_number 30\n", "species 246\n", "subspecies 155\n", "genus 94\n", "file_url 39297\n", "hybrid_stat 2\n", "filename 44809\n", "dtype: int64" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master[\"filename\"] = master[\"X\"].astype(str) + \"_\" + master[\"Image_name\"]\n", "master.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Our number of unique downloaded images is 69 less than the number of unique values of `Image_name`. For reference, we recorded 612 unique `CAMID`s in our error log of 2666 images that could not be downloaded.\n", "\n", "### Merge `master` and `checksums`" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(42143, 31)" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master_checksums = pd.merge(master,\n", " checksums,\n", " on = \"filename\",\n", " how = \"inner\")\n", "# Expectation is 42143 entries now\n", "master_checksums.shape" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 11968\n", "Image_name 36216\n", "X 42143\n", "filename 42143\n", "md5 36212\n", "file_url 36631\n", "dtype: int64" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "id_cols = [\"CAMID\", \"Image_name\", \"X\", \"filename\", \"md5\", \"file_url\"]\n", "master_checksums[id_cols].nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "23 CAMIDs lost, as expected from the error evaluation." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Did we lose any of our diversity? Taxonomic, image view, source (dataset or location of butterfly), etc. Only one stage is indicated in full master file." ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Taxonomic_Name 366\n", "species 246\n", "subspecies 155\n", "genus 94\n", "Cross_Type 30\n", "View 7\n", "Locality 644\n", "Sex 3\n", "Dataset 7\n", "dtype: int64" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stats_cols = [\"Taxonomic_Name\", \"species\", \"subspecies\", \"genus\", \"Cross_Type\", \"View\", \"Locality\", \"Sex\", \"Dataset\"]\n", "\n", "master_checksums[stats_cols].nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We lost one location and one dataset source to unsuccessful downloads.\n", "\n", "#### Check on Lost Representation" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "24204 Huaymayaco\n", "Name: Locality, dtype: object" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master.loc[~master[\"Locality\"].isin(list(master_checksums[\"Locality\"].unique())), \"Locality\"].sample()" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "24233 Cambridge Collection\n", "Name: Dataset, dtype: object" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master.loc[~master[\"Dataset\"].isin(list(master_checksums[\"Dataset\"].unique())), \"Dataset\"].sample()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Index: 47 entries, 24194 to 24240\n", "Data columns (total 29 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 CAMID 47 non-null object\n", " 1 X 47 non-null int64 \n", " 2 Image_name 47 non-null object\n", " 3 View 47 non-null object\n", " 4 zenodo_name 47 non-null object\n", " 5 zenodo_link 47 non-null object\n", " 6 Sequence 47 non-null object\n", " 7 Taxonomic_Name 47 non-null object\n", " 8 Locality 47 non-null object\n", " 9 Sample_accession 0 non-null object\n", " 10 Collected_by 0 non-null object\n", " 11 Other_ID 0 non-null object\n", " 12 Date 47 non-null object\n", " 13 Dataset 47 non-null object\n", " 14 Store 0 non-null object\n", " 15 Brood 0 non-null object\n", " 16 Death_Date 47 non-null object\n", " 17 Cross_Type 0 non-null object\n", " 18 Stage 0 non-null object\n", " 19 Sex 47 non-null object\n", " 20 Unit_Type 47 non-null object\n", " 21 file_type 47 non-null object\n", " 22 record_number 47 non-null int64 \n", " 23 species 47 non-null object\n", " 24 subspecies 47 non-null object\n", " 25 genus 47 non-null object\n", " 26 file_url 47 non-null object\n", " 27 hybrid_stat 47 non-null object\n", " 28 filename 47 non-null object\n", "dtypes: int64(2), object(27)\n", "memory usage: 11.0+ KB\n" ] } ], "source": [ "missing_samples = master.loc[(master[\"Locality\"] == \"Huaymayaco\") | (master[\"Dataset\"] == \"Cambridge Collection\")] \n", "missing_samples.info()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "record_number\n", "4289223 47\n", "Name: count, dtype: int64" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "missing_samples.record_number.value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This record ([4289223](https://zenodo.org/records/4289223)) was examined in `EDA-DL-0-2.ipynb`. The images were listed in the provided metadata file for that record, but they did not appear in the record itself.\n", "They are the majority of the images from Rachel Blow's Ecuador collection 2018 melpomene and timareta, near ikiam (taken in October 2019), listed in [0.2.rachel.blow.mel.tim.ikiam.csv](https://zenodo.org/records/4289223/preview/0.2.rachel.blow.mel.tim.ikiam.csv?include_deleted=0)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Explore Downloaded Images\n", "\n", "We have approximately 6000 duplicated images. We need to explore the information associated with each and reduce down to just unique images." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Are CAMIDs consistent in naming that duplicate images share CAMID (in same format)?" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(11858, 32)\n" ] }, { "data": { "text/plain": [ "CAMID 2815\n", "X 11858\n", "Image_name 5931\n", "View 2\n", "zenodo_name 15\n", "zenodo_link 15\n", "Sequence 2815\n", "Taxonomic_Name 195\n", "Locality 210\n", "Sample_accession 446\n", "Collected_by 0\n", "Other_ID 106\n", "Date 200\n", "Dataset 1\n", "Store 58\n", "Brood 9\n", "Death_Date 0\n", "Cross_Type 0\n", "Stage 0\n", "Sex 3\n", "Unit_Type 3\n", "file_type 3\n", "record_number 15\n", "species 121\n", "subspecies 93\n", "genus 38\n", "file_url 6346\n", "hybrid_stat 2\n", "filename 11858\n", "filepath 11858\n", "md5 5927\n", "duplicate_md5 1\n", "dtype: int64" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master_checksums[\"duplicate_md5\"] = master_checksums.duplicated(\"md5\", keep = False)\n", "duplicated_images = master_checksums.loc[master_checksums[\"duplicate_md5\"]]\n", "\n", "print(duplicated_images.shape)\n", "duplicated_images.nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Observations:\n", "- Half of the Zenodo records wind up with duplicated images. \n", "- `Image_name` uniqueness is close to `md5`, but there are 4 more unique image names than unique images. \n", "- None of the cross types are duplicated.\n", "- We do have multiple unique images for a single `CAMID`, more than just dorsal vs ventral since there are 2815 unique CAMIDs and 5927 unique `md5` values (5927 = 2x2815 + 297)" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [], "source": [ "# Save master file of all downloaded images with MD5s (no duplicate marker)\n", "master_checksums[list(master_checksums.columns)[:-1]].to_csv(\"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_downloaded.csv\", index = False)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9212" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master_checksums.loc[~master_checksums[\"duplicate_md5\"], \"CAMID\"].nunique()" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['CAMID',\n", " 'X',\n", " 'Image_name',\n", " 'View',\n", " 'zenodo_name',\n", " 'zenodo_link',\n", " 'Sequence',\n", " 'Taxonomic_Name',\n", " 'Locality',\n", " 'Sample_accession',\n", " 'Other_ID',\n", " 'Date',\n", " 'Dataset',\n", " 'Store',\n", " 'Brood',\n", " 'Sex',\n", " 'Unit_Type',\n", " 'file_type',\n", " 'record_number',\n", " 'species',\n", " 'subspecies',\n", " 'genus',\n", " 'file_url',\n", " 'hybrid_stat',\n", " 'filename',\n", " 'filepath',\n", " 'md5',\n", " 'duplicate_md5']" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "non_null_cols = [col for col in list(duplicated_images.columns) if duplicated_images.loc[duplicated_images[col].notna()].shape[0] > 0]\n", "non_null_cols" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let's remove all the columns with null values for easier analysis." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Index: 11858 entries, 3233 to 40186\n", "Data columns (total 28 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 CAMID 11858 non-null object\n", " 1 X 11858 non-null int64 \n", " 2 Image_name 11858 non-null object\n", " 3 View 11858 non-null object\n", " 4 zenodo_name 11858 non-null object\n", " 5 zenodo_link 11858 non-null object\n", " 6 Sequence 11858 non-null object\n", " 7 Taxonomic_Name 11858 non-null object\n", " 8 Locality 11836 non-null object\n", " 9 Sample_accession 1846 non-null object\n", " 10 Other_ID 830 non-null object\n", " 11 Date 10046 non-null object\n", " 12 Dataset 11614 non-null object\n", " 13 Store 11670 non-null object\n", " 14 Brood 808 non-null object\n", " 15 Sex 11474 non-null object\n", " 16 Unit_Type 11614 non-null object\n", " 17 file_type 11858 non-null object\n", " 18 record_number 11858 non-null int64 \n", " 19 species 11858 non-null object\n", " 20 subspecies 8200 non-null object\n", " 21 genus 11858 non-null object\n", " 22 file_url 11858 non-null object\n", " 23 hybrid_stat 8264 non-null object\n", " 24 filename 11858 non-null object\n", " 25 filepath 11858 non-null object\n", " 26 md5 11858 non-null object\n", " 27 duplicate_md5 11858 non-null bool \n", "dtypes: bool(1), int64(2), object(25)\n", "memory usage: 2.5+ MB\n" ] } ], "source": [ "duplicated_images = duplicated_images[non_null_cols]\n", "duplicated_images.info(show_counts=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "There is some inconsistency with label coverage, which is hopefully resolvable for duplciated images." ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "record_number\n", "3477891 5501\n", "2707828 1276\n", "2714333 1113\n", "2686762 980\n", "2684906 747\n", "2677821 703\n", "2813153 435\n", "4291095 415\n", "2702457 260\n", "2682458 148\n", "2682669 92\n", "2552371 91\n", "2550097 50\n", "2553977 27\n", "5526257 20\n", "Name: count, dtype: int64" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "duplicated_images.record_number.value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This is mostly record 3477891 and the number of duplicate images in record 3477891 (5501) matches with the number of images that were matched to the multimedia CSV from that record to do the download patch. If I remove all instances of record 3477891, will we still have duplicates and will we have the same number of unique images?\n", "\n", "### Check without Record 3477891" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "36642\n" ] }, { "data": { "text/plain": [ "CAMID 11968\n", "Image_name 36216\n", "X 36642\n", "filename 36642\n", "md5 36212\n", "file_url 36631\n", "dtype: int64" ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch = master_checksums.loc[master_checksums[\"record_number\"] != 3477891]\n", "\n", "print(no_patch.shape[0])\n", "no_patch[id_cols].nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yes, removing that record gives us the same number of unique images. ID Stats are consistent (unique MD5s and CAMIDs).\n", "\n", "We have 430 images that are duplicates (`X - md5`)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Would keeping it allow us to remove others?" ] }, { "cell_type": "code", "execution_count": 38, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 2704\n", "Image_name 5497\n", "X 10998\n", "filename 10998\n", "md5 5497\n", "file_url 5497\n", "dtype: int64" ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_3477891_urls = list(master_checksums.loc[master_checksums[\"record_number\"] == 3477891, \"file_url\"].unique())\n", "\n", "rec_3477891_images = master_checksums.loc[master_checksums[\"file_url\"].isin(rec_3477891_urls)]\n", "\n", "rec_3477891_images[id_cols].nunique()" ] }, { "cell_type": "code", "execution_count": 40, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "record_number\n", "3477891 5501\n", "2707828 1276\n", "2714333 1113\n", "2686762 980\n", "2684906 747\n", "2677821 703\n", "2702457 260\n", "2682458 148\n", "2682669 92\n", "2552371 89\n", "2550097 50\n", "2813153 20\n", "2553977 19\n", "Name: count, dtype: int64" ] }, "execution_count": 40, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_3477891_images.record_number.value_counts()" ] }, { "cell_type": "code", "execution_count": 41, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2677821\n", "X 769\n", "CAMID 387\n", "md5 769\n", "file_url 769\n", "dtype: int64\n", "\n", "3477891\n", "X 5501\n", "CAMID 2704\n", "md5 5497\n", "file_url 5497\n", "dtype: int64\n", "\n", "2682458\n", "X 950\n", "CAMID 476\n", "md5 950\n", "file_url 950\n", "dtype: int64\n", "\n", "2682669\n", "X 915\n", "CAMID 458\n", "md5 915\n", "file_url 915\n", "dtype: int64\n", "\n", "2684906\n", "X 977\n", "CAMID 492\n", "md5 977\n", "file_url 977\n", "dtype: int64\n", "\n", "2552371\n", "X 2392\n", "CAMID 1189\n", "md5 2391\n", "file_url 2392\n", "dtype: int64\n", "\n", "2553977\n", "X 158\n", "CAMID 79\n", "md5 154\n", "file_url 157\n", "dtype: int64\n", "\n", "2686762\n", "X 1384\n", "CAMID 694\n", "md5 1384\n", "file_url 1384\n", "dtype: int64\n", "\n", "2550097\n", "X 1400\n", "CAMID 351\n", "md5 1400\n", "file_url 1400\n", "dtype: int64\n", "\n", "2702457\n", "X 771\n", "CAMID 388\n", "md5 771\n", "file_url 771\n", "dtype: int64\n", "\n", "2813153\n", "X 523\n", "CAMID 158\n", "md5 523\n", "file_url 523\n", "dtype: int64\n", "\n", "2707828\n", "X 1292\n", "CAMID 646\n", "md5 1292\n", "file_url 1292\n", "dtype: int64\n", "\n", "2714333\n", "X 1356\n", "CAMID 647\n", "md5 1356\n", "file_url 1356\n", "dtype: int64\n", "\n" ] } ], "source": [ "for record in list(rec_3477891_images.record_number.unique()):\n", " print(record)\n", " temp = master_checksums.loc[master_checksums[\"record_number\"] == record]\n", " print(temp[[\"X\",\"CAMID\", \"md5\", \"file_url\"]].nunique())\n", " print()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Definitely cleaner to just remove record 3477891." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "4289223\n", "X 145\n", "CAMID 73\n", "md5 145\n", "file_url 145\n", "dtype: int64\n", "\n", "4288311\n", "X 3088\n", "CAMID 1050\n", "md5 3088\n", "file_url 3088\n", "dtype: int64\n", "\n", "2677821\n", "X 769\n", "CAMID 387\n", "md5 769\n", "file_url 769\n", "dtype: int64\n", "\n", "2682458\n", "X 950\n", "CAMID 476\n", "md5 950\n", "file_url 950\n", "dtype: int64\n", "\n", "2682669\n", "X 915\n", "CAMID 458\n", "md5 915\n", "file_url 915\n", "dtype: int64\n", "\n", "2684906\n", "X 977\n", "CAMID 492\n", "md5 977\n", "file_url 977\n", "dtype: int64\n", "\n", "2552371\n", "X 2392\n", "CAMID 1189\n", "md5 2391\n", "file_url 2392\n", "dtype: int64\n", "\n", "2553977\n", "X 158\n", "CAMID 79\n", "md5 154\n", "file_url 157\n", "dtype: int64\n", "\n", "2686762\n", "X 1384\n", "CAMID 694\n", "md5 1384\n", "file_url 1384\n", "dtype: int64\n", "\n", "2549524\n", "X 1471\n", "CAMID 368\n", "md5 1471\n", "file_url 1471\n", "dtype: int64\n", "\n", "2550097\n", "X 1400\n", "CAMID 351\n", "md5 1400\n", "file_url 1400\n", "dtype: int64\n", "\n", "4153502\n", "X 583\n", "CAMID 147\n", "md5 583\n", "file_url 583\n", "dtype: int64\n", "\n", "3082688\n", "X 2917\n", "CAMID 1467\n", "md5 2917\n", "file_url 2917\n", "dtype: int64\n", "\n", "2813153\n", "X 523\n", "CAMID 158\n", "md5 523\n", "file_url 523\n", "dtype: int64\n", "\n", "1748277\n", "X 1992\n", "CAMID 499\n", "md5 1992\n", "file_url 1992\n", "dtype: int64\n", "\n", "2702457\n", "X 771\n", "CAMID 388\n", "md5 771\n", "file_url 771\n", "dtype: int64\n", "\n", "2548678\n", "X 1298\n", "CAMID 325\n", "md5 1298\n", "file_url 1298\n", "dtype: int64\n", "\n", "5561246\n", "X 1478\n", "CAMID 371\n", "md5 1478\n", "file_url 1478\n", "dtype: int64\n", "\n", "2707828\n", "X 1292\n", "CAMID 646\n", "md5 1292\n", "file_url 1292\n", "dtype: int64\n", "\n", "2714333\n", "X 1356\n", "CAMID 647\n", "md5 1356\n", "file_url 1356\n", "dtype: int64\n", "\n", "4291095\n", "X 2212\n", "CAMID 553\n", "md5 2212\n", "file_url 2212\n", "dtype: int64\n", "\n", "3569598\n", "X 1618\n", "CAMID 377\n", "md5 1618\n", "file_url 1618\n", "dtype: int64\n", "\n", "4287444\n", "X 1188\n", "CAMID 269\n", "md5 1188\n", "file_url 1188\n", "dtype: int64\n", "\n", "4288250\n", "X 2593\n", "CAMID 579\n", "md5 2593\n", "file_url 2593\n", "dtype: int64\n", "\n", "5526257\n", "X 1324\n", "CAMID 330\n", "md5 1314\n", "file_url 1314\n", "dtype: int64\n", "\n", "2553501\n", "X 464\n", "CAMID 232\n", "md5 464\n", "file_url 464\n", "dtype: int64\n", "\n", "2735056\n", "X 452\n", "CAMID 113\n", "md5 452\n", "file_url 452\n", "dtype: int64\n", "\n", "2554218\n", "X 492\n", "CAMID 123\n", "md5 492\n", "file_url 492\n", "dtype: int64\n", "\n", "2555086\n", "X 440\n", "CAMID 110\n", "md5 440\n", "file_url 440\n", "dtype: int64\n", "\n" ] } ], "source": [ "for record in list(no_patch.record_number.unique()):\n", " print(record)\n", " temp = no_patch.loc[no_patch[\"record_number\"] == record]\n", " print(temp[[\"X\",\"CAMID\", \"md5\", \"file_url\"]].nunique())\n", " print()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Two records have a few duplicate images within them (record 2552371 has 1 and record 2553977 has 3)." ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_74270/343859278.py:1: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " no_patch[\"duplicate_md5\"] = no_patch.duplicated(\"md5\", keep = False)\n" ] }, { "data": { "text/plain": [ "duplicate_md5\n", "False 35782\n", "True 860\n", "Name: count, dtype: int64" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch[\"duplicate_md5\"] = no_patch.duplicated(\"md5\", keep = False)\n", "no_patch[\"duplicate_md5\"].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yes, we still have duplicates." ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 11864\n", "Image_name 35782\n", "X 35782\n", "filename 35782\n", "md5 35782\n", "file_url 35782\n", "dtype: int64" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "non_dupes = no_patch.loc[~no_patch[\"duplicate_md5\"]]\n", "non_dupes[id_cols].nunique()" ] }, { "cell_type": "code", "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "View\n", "dorsal 17019\n", "ventral 16954\n", "hindwing dorsal 254\n", "hindwing ventral 254\n", "forewing dorsal 252\n", "forewing ventral 252\n", "dorsal and ventral 18\n", "Name: count, dtype: int64" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "non_dupes.View.value_counts()" ] }, { "cell_type": "code", "execution_count": 48, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "file_type\n", "jpg 25618\n", "raw 10111\n", "tif 53\n", "Name: count, dtype: int64" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "non_dupes.file_type.value_counts()" ] }, { "cell_type": "code", "execution_count": 50, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "View\n", "dorsal 12405\n", "ventral 12342\n", "hindwing dorsal 127\n", "hindwing ventral 127\n", "forewing dorsal 126\n", "forewing ventral 126\n", "dorsal and ventral 18\n", "Name: count, dtype: int64" ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "non_dupes.loc[non_dupes[\"file_type\"] != \"raw\", \"View\"].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "So among our non-duplicated images we do see multiple images of the same specimen after accounting for file type and view of the specimen (as determined by the number of ventral or dorsal images)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Explore the duplicates\n", "Ensure that we maintain all the available metadata associated with the images as we remove duplicates." ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Index: 860 entries, 11978 to 40145\n", "Data columns (total 28 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 CAMID 860 non-null object\n", " 1 X 860 non-null int64 \n", " 2 Image_name 860 non-null object\n", " 3 View 860 non-null object\n", " 4 zenodo_name 860 non-null object\n", " 5 zenodo_link 860 non-null object\n", " 6 Sequence 860 non-null object\n", " 7 Taxonomic_Name 860 non-null object\n", " 8 Locality 838 non-null object\n", " 9 Sample_accession 0 non-null object\n", " 10 Other_ID 806 non-null object\n", " 11 Date 0 non-null object\n", " 12 Dataset 616 non-null object\n", " 13 Store 832 non-null object\n", " 14 Brood 800 non-null object\n", " 15 Sex 608 non-null object\n", " 16 Unit_Type 616 non-null object\n", " 17 file_type 860 non-null object\n", " 18 record_number 860 non-null int64 \n", " 19 species 860 non-null object\n", " 20 subspecies 858 non-null object\n", " 21 genus 860 non-null object\n", " 22 file_url 860 non-null object\n", " 23 hybrid_stat 858 non-null object\n", " 24 filename 860 non-null object\n", " 25 filepath 860 non-null object\n", " 26 md5 860 non-null object\n", " 27 duplicate_md5 860 non-null bool \n", "dtypes: bool(1), int64(2), object(25)\n", "memory usage: 189.0+ KB\n" ] } ], "source": [ "no_patch_duplicates = no_patch.loc[no_patch[\"duplicate_md5\"]]\n", "\n", "no_patch_duplicates[non_null_cols].info()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A couple more nulls were introduced." ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 111\n", "Image_name 434\n", "X 860\n", "filename 860\n", "md5 430\n", "file_url 849\n", "dtype: int64" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch_duplicates[id_cols].nunique()" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Taxonomic_Name 4\n", "species 3\n", "subspecies 3\n", "genus 1\n", "Cross_Type 0\n", "View 2\n", "Locality 6\n", "Sex 2\n", "Dataset 1\n", "dtype: int64" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch_duplicates[stats_cols].nunique()" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "record_number\n", "4291095 415\n", "2813153 415\n", "5526257 20\n", "2553977 8\n", "2552371 2\n", "Name: count, dtype: int64" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch_duplicates.record_number.value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looks like we just have two of each image.\n", "\n", "I'd hazard a guess that records [4291095](https://zenodo.org/records/4291095) and [2813153](https://zenodo.org/records/2813153) are duplicates of each other and contain some of the images from the others (as there are 430 unique images).\n", "\n", "based on their descriptions (on Zenodo) it doesn't seem like they should have any overlap..." ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...record_numberspeciessubspeciesgenusfile_urlhybrid_statfilenamefilepathmd5duplicate_md5
32499CAM04180740194CAM041807_d.CR2dorsal0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,807Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40194_CAM041807_d.CR2images/Heliconius erato ssp. lativitta/40194_C...1ef3dbe7b286a34882d21ef39424f18aTrue
32502CAM04180740197CAM041807_v.JPGventral0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,807Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40197_CAM041807_v.JPGimages/Heliconius erato ssp. lativitta/40197_C...844f9b09adda5d919694a8c1a38ca991True
32504CAM04180740195CAM041807_d.JPGdorsal0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,807Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40195_CAM041807_d.JPGimages/Heliconius erato ssp. lativitta/40195_C...1e77684537bc187b8e82b0f9f4342275True
32505CAM04180740196CAM041807_v.CR2ventral0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,807Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40196_CAM041807_v.CR2images/Heliconius erato ssp. lativitta/40196_C...b1daeb529e16952906c986d193bcc32dTrue
32507CAM04180840198CAM041808_d.CR2dorsal0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,808Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40198_CAM041808_d.CR2images/Heliconius erato ssp. lativitta/40198_C...e1b16f08005517abfda5ef098b11b8b1True
32511CAM04180840201CAM041808_v.JPGventral0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,808Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40201_CAM041808_v.JPGimages/Heliconius erato ssp. lativitta/40201_C...3325bc1d4bf98f1b49a7f9b1580cbf8dTrue
32512CAM04180840199CAM041808_d.JPGdorsal0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,808Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40199_CAM041808_d.JPGimages/Heliconius erato ssp. lativitta/40199_C...5498918119fbcbdf714d3f31388336a2True
32513CAM04180840200CAM041808_v.CR2ventral0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,808Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40200_CAM041808_v.CR2images/Heliconius erato ssp. lativitta/40200_C...241d924503c32d33c44d0e6863da4d9cTrue
32517CAM04180940203CAM041809_d.JPGdorsal0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,809Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40203_CAM041809_d.JPGimages/Heliconius erato ssp. lativitta/40203_C...6ab1ecd5eaf4b38bbe441565bc8b87abTrue
32518CAM04180940205CAM041809_v.JPGventral0.gmk.broods.all.csvhttps://zenodo.org/record/429109541,809Heliconius erato ssp. lativittaIkiam MariposarioNaN...4291095Heliconius eratolativittaHeliconiushttps://zenodo.org/record/4291095/files/CAM041...non-hybrid40205_CAM041809_v.JPGimages/Heliconius erato ssp. lativitta/40205_C...78508c7ea9cf973b2d3dfe4d91fc11f1True
\n", "

10 rows × 32 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View zenodo_name \\\n", "32499 CAM041807 40194 CAM041807_d.CR2 dorsal 0.gmk.broods.all.csv \n", "32502 CAM041807 40197 CAM041807_v.JPG ventral 0.gmk.broods.all.csv \n", "32504 CAM041807 40195 CAM041807_d.JPG dorsal 0.gmk.broods.all.csv \n", "32505 CAM041807 40196 CAM041807_v.CR2 ventral 0.gmk.broods.all.csv \n", "32507 CAM041808 40198 CAM041808_d.CR2 dorsal 0.gmk.broods.all.csv \n", "32511 CAM041808 40201 CAM041808_v.JPG ventral 0.gmk.broods.all.csv \n", "32512 CAM041808 40199 CAM041808_d.JPG dorsal 0.gmk.broods.all.csv \n", "32513 CAM041808 40200 CAM041808_v.CR2 ventral 0.gmk.broods.all.csv \n", "32517 CAM041809 40203 CAM041809_d.JPG dorsal 0.gmk.broods.all.csv \n", "32518 CAM041809 40205 CAM041809_v.JPG ventral 0.gmk.broods.all.csv \n", "\n", " zenodo_link Sequence \\\n", "32499 https://zenodo.org/record/4291095 41,807 \n", "32502 https://zenodo.org/record/4291095 41,807 \n", "32504 https://zenodo.org/record/4291095 41,807 \n", "32505 https://zenodo.org/record/4291095 41,807 \n", "32507 https://zenodo.org/record/4291095 41,808 \n", "32511 https://zenodo.org/record/4291095 41,808 \n", "32512 https://zenodo.org/record/4291095 41,808 \n", "32513 https://zenodo.org/record/4291095 41,808 \n", "32517 https://zenodo.org/record/4291095 41,809 \n", "32518 https://zenodo.org/record/4291095 41,809 \n", "\n", " Taxonomic_Name Locality Sample_accession \\\n", "32499 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32502 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32504 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32505 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32507 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32511 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32512 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32513 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32517 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "32518 Heliconius erato ssp. lativitta Ikiam Mariposario NaN \n", "\n", " ... record_number species subspecies genus \\\n", "32499 ... 4291095 Heliconius erato lativitta Heliconius \n", "32502 ... 4291095 Heliconius erato lativitta Heliconius \n", "32504 ... 4291095 Heliconius erato lativitta Heliconius \n", "32505 ... 4291095 Heliconius erato lativitta Heliconius \n", "32507 ... 4291095 Heliconius erato lativitta Heliconius \n", "32511 ... 4291095 Heliconius erato lativitta Heliconius \n", "32512 ... 4291095 Heliconius erato lativitta Heliconius \n", "32513 ... 4291095 Heliconius erato lativitta Heliconius \n", "32517 ... 4291095 Heliconius erato lativitta Heliconius \n", "32518 ... 4291095 Heliconius erato lativitta Heliconius \n", "\n", " file_url hybrid_stat \\\n", "32499 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32502 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32504 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32505 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32507 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32511 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32512 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32513 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32517 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "32518 https://zenodo.org/record/4291095/files/CAM041... non-hybrid \n", "\n", " filename \\\n", "32499 40194_CAM041807_d.CR2 \n", "32502 40197_CAM041807_v.JPG \n", "32504 40195_CAM041807_d.JPG \n", "32505 40196_CAM041807_v.CR2 \n", "32507 40198_CAM041808_d.CR2 \n", "32511 40201_CAM041808_v.JPG \n", "32512 40199_CAM041808_d.JPG \n", "32513 40200_CAM041808_v.CR2 \n", "32517 40203_CAM041809_d.JPG \n", "32518 40205_CAM041809_v.JPG \n", "\n", " filepath \\\n", "32499 images/Heliconius erato ssp. lativitta/40194_C... \n", "32502 images/Heliconius erato ssp. lativitta/40197_C... \n", "32504 images/Heliconius erato ssp. lativitta/40195_C... \n", "32505 images/Heliconius erato ssp. lativitta/40196_C... \n", "32507 images/Heliconius erato ssp. lativitta/40198_C... \n", "32511 images/Heliconius erato ssp. lativitta/40201_C... \n", "32512 images/Heliconius erato ssp. lativitta/40199_C... \n", "32513 images/Heliconius erato ssp. lativitta/40200_C... \n", "32517 images/Heliconius erato ssp. lativitta/40203_C... \n", "32518 images/Heliconius erato ssp. lativitta/40205_C... \n", "\n", " md5 duplicate_md5 \n", "32499 1ef3dbe7b286a34882d21ef39424f18a True \n", "32502 844f9b09adda5d919694a8c1a38ca991 True \n", "32504 1e77684537bc187b8e82b0f9f4342275 True \n", "32505 b1daeb529e16952906c986d193bcc32d True \n", "32507 e1b16f08005517abfda5ef098b11b8b1 True \n", "32511 3325bc1d4bf98f1b49a7f9b1580cbf8d True \n", "32512 5498918119fbcbdf714d3f31388336a2 True \n", "32513 241d924503c32d33c44d0e6863da4d9c True \n", "32517 6ab1ecd5eaf4b38bbe441565bc8b87ab True \n", "32518 78508c7ea9cf973b2d3dfe4d91fc11f1 True \n", "\n", "[10 rows x 32 columns]" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 4291095].head(10)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/var/folders/nv/f0fq1p1n1_3b11x579py_0q80000gq/T/ipykernel_74270/3053018095.py:2: SettingWithCopyWarning: \n", "A value is trying to be set on a copy of a slice from a DataFrame.\n", "Try using .loc[row_indexer,col_indexer] = value instead\n", "\n", "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n", " rec_4291095[\"dupes\"] = rec_4291095.duplicated(\"md5\")\n" ] }, { "data": { "text/plain": [ "dupes\n", "False 415\n", "Name: count, dtype: int64" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_4291095 = no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 4291095]\n", "rec_4291095[\"dupes\"] = rec_4291095.duplicated(\"md5\")\n", "rec_4291095[\"dupes\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 42, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "415" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"].isin([4291095, 2813153]), \"md5\"].nunique()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These shouldn't be duplicates based on their Zenodo descriptions. Let's download their CSV files and check the metadata matches." ] }, { "cell_type": "code", "execution_count": 43, "metadata": {}, "outputs": [], "source": [ "df_4291095 = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/0.gmk.broods.all_(rec4291095).csv\", low_memory=False)\n", "df_2813153 = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/CAM.coll.images.batch10_(rec2813153).csv\", low_memory=False)" ] }, { "cell_type": "code", "execution_count": 44, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2220, 591)" ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_4291095.shape[0], df_2813153.shape[0]" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "record_number\n", "4291095 2212\n", "2813153 523\n", "Name: count, dtype: int64" ] }, "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master_checksums.loc[master_checksums[\"record_number\"].isin([4291095, 2813153]), \"record_number\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 52, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['image.name', 'unit.id', 'side'], dtype='object')" ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_4291095.columns" ] }, { "cell_type": "code", "execution_count": 94, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2212" ] }, "execution_count": 94, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_4291095_check = pd.merge(master_checksums.loc[master_checksums[\"record_number\"] == 4291095],\n", " df_4291095,\n", " left_on = \"Image_name\",\n", " right_on = \"image.name\",\n", " how = \"inner\")\n", "\n", "rec_4291095_check.shape[0]" ] }, { "cell_type": "code", "execution_count": 54, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['Filename', 'UnitID', 'View'], dtype='object')" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df_2813153.columns" ] }, { "cell_type": "code", "execution_count": 55, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "523" ] }, "execution_count": 55, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_2813153_check = pd.merge(master_checksums.loc[master_checksums[\"record_number\"] == 2813153],\n", " df_2813153,\n", " left_on = \"Image_name\",\n", " right_on = \"Filename\",\n", " how = \"inner\")\n", "\n", "rec_2813153_check.shape[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These do both seem to align properly, are the `UnitID`/`unit.id` overlapping for 415 images?" ] }, { "cell_type": "code", "execution_count": 62, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "415\n" ] }, { "data": { "text/plain": [ "X_x 415\n", "Image_name_x 415\n", "CAMID 104\n", "unit.id 104\n", "md5 415\n", "Taxonomic_Name 1\n", "X_y 415\n", "Image_name_y 415\n", "UnitID 104\n", "dtype: int64" ] }, "execution_count": 62, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_match = pd.merge(rec_4291095_check[[\"X\", \"Image_name\", \"CAMID\", \"unit.id\", \"md5\", \"Taxonomic_Name\"]],\n", " rec_2813153_check[[\"X\", \"Image_name\", \"CAMID\", \"UnitID\", \"md5\", \"Taxonomic_Name\"]],\n", " left_on = [\"CAMID\", \"unit.id\", \"Taxonomic_Name\", \"md5\"],\n", " right_on = [\"CAMID\", \"UnitID\", \"Taxonomic_Name\", \"md5\"],\n", " how = \"inner\")\n", "\n", "print(rec_match.shape[0])\n", "rec_match.nunique()" ] }, { "cell_type": "code", "execution_count": 63, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_xImage_name_xCAMIDunit.idmd5Taxonomic_NameX_yImage_name_yUnitID
040194CAM041807_d.CR2CAM041807CAM0418071ef3dbe7b286a34882d21ef39424f18aHeliconius erato ssp. lativitta14461CAM041807_d.CR2CAM041807
140197CAM041807_v.JPGCAM041807CAM041807844f9b09adda5d919694a8c1a38ca991Heliconius erato ssp. lativitta14464CAM041807_v.JPGCAM041807
240195CAM041807_d.JPGCAM041807CAM0418071e77684537bc187b8e82b0f9f4342275Heliconius erato ssp. lativitta14462CAM041807_d.JPGCAM041807
340196CAM041807_v.CR2CAM041807CAM041807b1daeb529e16952906c986d193bcc32dHeliconius erato ssp. lativitta14463CAM041807_v.CR2CAM041807
440198CAM041808_d.CR2CAM041808CAM041808e1b16f08005517abfda5ef098b11b8b1Heliconius erato ssp. lativitta14465CAM041808_d.CR2CAM041808
\n", "
" ], "text/plain": [ " X_x Image_name_x CAMID unit.id \\\n", "0 40194 CAM041807_d.CR2 CAM041807 CAM041807 \n", "1 40197 CAM041807_v.JPG CAM041807 CAM041807 \n", "2 40195 CAM041807_d.JPG CAM041807 CAM041807 \n", "3 40196 CAM041807_v.CR2 CAM041807 CAM041807 \n", "4 40198 CAM041808_d.CR2 CAM041808 CAM041808 \n", "\n", " md5 Taxonomic_Name X_y \\\n", "0 1ef3dbe7b286a34882d21ef39424f18a Heliconius erato ssp. lativitta 14461 \n", "1 844f9b09adda5d919694a8c1a38ca991 Heliconius erato ssp. lativitta 14464 \n", "2 1e77684537bc187b8e82b0f9f4342275 Heliconius erato ssp. lativitta 14462 \n", "3 b1daeb529e16952906c986d193bcc32d Heliconius erato ssp. lativitta 14463 \n", "4 e1b16f08005517abfda5ef098b11b8b1 Heliconius erato ssp. lativitta 14465 \n", "\n", " Image_name_y UnitID \n", "0 CAM041807_d.CR2 CAM041807 \n", "1 CAM041807_v.JPG CAM041807 \n", "2 CAM041807_d.JPG CAM041807 \n", "3 CAM041807_v.CR2 CAM041807 \n", "4 CAM041808_d.CR2 CAM041808 " ] }, "execution_count": 63, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_match.head()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The big question in removing duplicate records is just if all the metadata assoicated to the image remains the same. This would be all metadata other than `record_number`, `file_url`, `X`, `zenodo_link`, `zenodo_name` (CSV source), `Dataset` (Zenodo record name), `Image_name`, and possibly some other columns we don't usually work with." ] }, { "cell_type": "code", "execution_count": 71, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['CAMID',\n", " 'View',\n", " 'Sequence',\n", " 'Taxonomic_Name',\n", " 'Locality',\n", " 'Other_ID',\n", " 'Store',\n", " 'Brood',\n", " 'Sex',\n", " 'Unit_Type',\n", " 'file_type',\n", " 'species',\n", " 'subspecies',\n", " 'genus',\n", " 'hybrid_stat',\n", " 'md5']" ] }, "execution_count": 71, "metadata": {}, "output_type": "execute_result" } ], "source": [ "diff_cols = [\"record_number\", \"file_url\", \"X\", \"zenodo_link\", \"zenodo_name\", \"filename\", \"filepath\", \"Image_name\", \"Dataset\"]\n", "\n", "merge_cols = [col for col in list(no_patch_duplicates.columns)[:-1] if (no_patch_duplicates.loc[no_patch_duplicates[col].notna()].shape[0] > 0) and (col not in diff_cols)]\n", "merge_cols" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start with these two larger overlaps" ] }, { "cell_type": "code", "execution_count": 95, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(415, 32)" ] }, "execution_count": 95, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_2813153 = no_patch_duplicates.loc[no_patch_duplicates[\"record_number\"] == 2813153]\n", "rec_2813153.shape" ] }, { "cell_type": "code", "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "311" ] }, "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ "merge_check = pd.merge(rec_4291095,\n", " rec_2813153,\n", " on = merge_cols,\n", " how = \"inner\")\n", "\n", "merge_check.shape[0]" ] }, { "cell_type": "code", "execution_count": 111, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['CAMID',\n", " 'X',\n", " 'Image_name',\n", " 'View',\n", " 'zenodo_name',\n", " 'zenodo_link',\n", " 'Sequence',\n", " 'Taxonomic_Name',\n", " 'Locality',\n", " 'Other_ID',\n", " 'Dataset',\n", " 'Store',\n", " 'Brood',\n", " 'Sex',\n", " 'Unit_Type',\n", " 'file_type',\n", " 'record_number',\n", " 'species',\n", " 'subspecies',\n", " 'genus',\n", " 'file_url',\n", " 'hybrid_stat',\n", " 'filename',\n", " 'filepath',\n", " 'md5']" ] }, "execution_count": 111, "metadata": {}, "output_type": "execute_result" } ], "source": [ "overlap_non_null_cols = [col for col in list(no_patch_duplicates.columns)[:-1] if (no_patch_duplicates.loc[no_patch_duplicates[col].notna()].shape[0] > 0)]\n", "overlap_non_null_cols" ] }, { "cell_type": "code", "execution_count": 113, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CAMID 415\n", "X 0\n", "Image_name 415\n", "View 311\n", "zenodo_name 0\n", "zenodo_link 0\n", "Sequence 415\n", "Taxonomic_Name 415\n", "Locality 415\n", "Other_ID 415\n", "Dataset 415\n", "Store 415\n", "Brood 415\n", "Sex 415\n", "Unit_Type 415\n", "file_type 415\n", "record_number 0\n", "species 415\n", "subspecies 415\n", "genus 415\n", "file_url 0\n", "hybrid_stat 415\n", "filename 0\n", "filepath 0\n", "md5 415\n" ] } ], "source": [ "for col in overlap_non_null_cols:\n", " merge_on = [\"md5\", col]\n", " temp = pd.merge(rec_2813153,\n", " rec_4291095,\n", " on = merge_on,\n", " how = \"inner\")\n", " print(col, temp.shape[0])\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Expected columns fail, but also `View` seems to be an issue, so let's look at where the view disagrees. Note that the `Image_name` seems to match for all of them, this could be an option for checking proper views." ] }, { "cell_type": "code", "execution_count": 130, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(415, 9)" ] }, "execution_count": 130, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view_check_cols = [\"X\", \"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\", \"View\", \"file_type\"]\n", "view_check = pd.merge(rec_2813153[view_check_cols],\n", " rec_4291095[view_check_cols],\n", " on = [\"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\", \"file_type\"],\n", " suffixes = (\"_28\", \"_42\"),\n", " how = \"inner\")\n", "\n", "view_check.shape" ] }, { "cell_type": "code", "execution_count": 131, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "mismatched_view\n", "False 311\n", "True 104\n", "Name: count, dtype: int64" ] }, "execution_count": 131, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view_check[\"mismatched_view\"] = view_check[\"View_28\"] != view_check[\"View_42\"]\n", "view_check[\"mismatched_view\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 132, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_28Image_nameCAMIDmd5Taxonomic_NameView_28file_typeX_42View_42mismatched_view
13614599CAM041841_v.CR2CAM041841005a48b915e7c5a750648e5f37ea5fd8Heliconius erato ssp. lativittadorsalraw40332ventralTrue
11814579CAM041836_v.CR2CAM0418366c816d18dc8c903fbdbfb93f4c04c3b0Heliconius erato ssp. lativittadorsalraw40312ventralTrue
14814611CAM041844_v.CR2CAM04184459e2410288a9636c691086cc3720c761Heliconius erato ssp. lativittadorsalraw40344ventralTrue
5614519CAM041821_v.CR2CAM04182157163f6da6697359d233a6e712373b7dHeliconius erato ssp. lativittadorsalraw40252ventralTrue
28114743CAM041878_v.CR2CAM041878171701048825a19051127dc253e39e50Heliconius erato ssp. lativittadorsalraw40477ventralTrue
8614547CAM041828_v.CR2CAM041828c6de0b670edbe46881497bf60b1f9853Heliconius erato ssp. lativittadorsalraw40280ventralTrue
19414655CAM041856_v.CR2CAM0418566f5face02339ba69483f6dbf6c0aa601Heliconius erato ssp. lativittadorsalraw40389ventralTrue
1814479CAM041811_v.CR2CAM0418119cb25be5951488b9e37342586cb678f6Heliconius erato ssp. lativittadorsalraw40212ventralTrue
29014751CAM041880_v.CR2CAM041880b27fa3842baba1f3bb1679419dd009e7Heliconius erato ssp. lativittadorsalraw40485ventralTrue
31014771CAM041885_v.CR2CAM041885d7105469b2c4b24fb288e7e3b9b1241dHeliconius erato ssp. lativittadorsalraw40505ventralTrue
\n", "
" ], "text/plain": [ " X_28 Image_name CAMID md5 \\\n", "136 14599 CAM041841_v.CR2 CAM041841 005a48b915e7c5a750648e5f37ea5fd8 \n", "118 14579 CAM041836_v.CR2 CAM041836 6c816d18dc8c903fbdbfb93f4c04c3b0 \n", "148 14611 CAM041844_v.CR2 CAM041844 59e2410288a9636c691086cc3720c761 \n", "56 14519 CAM041821_v.CR2 CAM041821 57163f6da6697359d233a6e712373b7d \n", "281 14743 CAM041878_v.CR2 CAM041878 171701048825a19051127dc253e39e50 \n", "86 14547 CAM041828_v.CR2 CAM041828 c6de0b670edbe46881497bf60b1f9853 \n", "194 14655 CAM041856_v.CR2 CAM041856 6f5face02339ba69483f6dbf6c0aa601 \n", "18 14479 CAM041811_v.CR2 CAM041811 9cb25be5951488b9e37342586cb678f6 \n", "290 14751 CAM041880_v.CR2 CAM041880 b27fa3842baba1f3bb1679419dd009e7 \n", "310 14771 CAM041885_v.CR2 CAM041885 d7105469b2c4b24fb288e7e3b9b1241d \n", "\n", " Taxonomic_Name View_28 file_type X_42 View_42 \\\n", "136 Heliconius erato ssp. lativitta dorsal raw 40332 ventral \n", "118 Heliconius erato ssp. lativitta dorsal raw 40312 ventral \n", "148 Heliconius erato ssp. lativitta dorsal raw 40344 ventral \n", "56 Heliconius erato ssp. lativitta dorsal raw 40252 ventral \n", "281 Heliconius erato ssp. lativitta dorsal raw 40477 ventral \n", "86 Heliconius erato ssp. lativitta dorsal raw 40280 ventral \n", "194 Heliconius erato ssp. lativitta dorsal raw 40389 ventral \n", "18 Heliconius erato ssp. lativitta dorsal raw 40212 ventral \n", "290 Heliconius erato ssp. lativitta dorsal raw 40485 ventral \n", "310 Heliconius erato ssp. lativitta dorsal raw 40505 ventral \n", "\n", " mismatched_view \n", "136 True \n", "118 True \n", "148 True \n", "56 True \n", "281 True \n", "86 True \n", "194 True \n", "18 True \n", "290 True \n", "310 True " ] }, "execution_count": 132, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view_check.loc[view_check[\"mismatched_view\"]].sample(10)" ] }, { "cell_type": "code", "execution_count": 133, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "file_type\n", "raw 104\n", "Name: count, dtype: int64" ] }, "execution_count": 133, "metadata": {}, "output_type": "execute_result" } ], "source": [ "view_check.loc[view_check[\"mismatched_view\"], \"file_type\"].value_counts()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ahh only the raw photos have the mismatch. Were they the only ones mislabeled or were their associated JPGs mislabeled?" ] }, { "cell_type": "code", "execution_count": 134, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_28Image_nameCAMIDmd5Taxonomic_NameView_28file_typeX_42View_42mismatched_view
27614738CAM041877_d.JPGCAM0418777cba96d6031a6c4b8ccdb9971a5f9728Heliconius erato ssp. lativittadorsaljpg40472dorsalFalse
12114582CAM041837_d.JPGCAM041837a7cc8d0b392b2088e122b736e8a09650Heliconius erato ssp. lativittadorsaljpg40315dorsalFalse
34614810CAM041895_d.JPGCAM04189560d3c82b6c57c08e3c71b73982aa1f09Heliconius erato ssp. lativittadorsaljpg40544dorsalFalse
27814740CAM041877_v.JPGCAM04187746eaec54590b045ab352728a4b12441aHeliconius erato ssp. lativittaventraljpg40474ventralFalse
18014644CAM041852_v.JPGCAM04185240b5d568cf0ab0590756181307dbf3dfHeliconius erato ssp. lativittaventraljpg40377ventralFalse
17614638CAM041851_d.JPGCAM0418516e0ef053a5208fb33fe612777e85fe90Heliconius erato ssp. lativittadorsaljpg40371dorsalFalse
10314564CAM041832_v.JPGCAM041832a0f4b27b90a322c36c26d8375f303adbHeliconius erato ssp. lativittaventraljpg40297ventralFalse
7414534CAM041825_d.JPGCAM041825795185b9e27ff897d94278a11eec5c99Heliconius erato ssp. lativittadorsaljpg40267dorsalFalse
18614646CAM041853_d.JPGCAM0418539f3ad95d8ff999ac4b8bb76cad171aafHeliconius erato ssp. lativittadorsaljpg40379dorsalFalse
28314742CAM041878_d.JPGCAM041878c0d154ebbf7552bcdbcb233556a5f286Heliconius erato ssp. lativittadorsaljpg40476dorsalFalse
\n", "
" ], "text/plain": [ " X_28 Image_name CAMID md5 \\\n", "276 14738 CAM041877_d.JPG CAM041877 7cba96d6031a6c4b8ccdb9971a5f9728 \n", "121 14582 CAM041837_d.JPG CAM041837 a7cc8d0b392b2088e122b736e8a09650 \n", "346 14810 CAM041895_d.JPG CAM041895 60d3c82b6c57c08e3c71b73982aa1f09 \n", "278 14740 CAM041877_v.JPG CAM041877 46eaec54590b045ab352728a4b12441a \n", "180 14644 CAM041852_v.JPG CAM041852 40b5d568cf0ab0590756181307dbf3df \n", "176 14638 CAM041851_d.JPG CAM041851 6e0ef053a5208fb33fe612777e85fe90 \n", "103 14564 CAM041832_v.JPG CAM041832 a0f4b27b90a322c36c26d8375f303adb \n", "74 14534 CAM041825_d.JPG CAM041825 795185b9e27ff897d94278a11eec5c99 \n", "186 14646 CAM041853_d.JPG CAM041853 9f3ad95d8ff999ac4b8bb76cad171aaf \n", "283 14742 CAM041878_d.JPG CAM041878 c0d154ebbf7552bcdbcb233556a5f286 \n", "\n", " Taxonomic_Name View_28 file_type X_42 View_42 \\\n", "276 Heliconius erato ssp. lativitta dorsal jpg 40472 dorsal \n", "121 Heliconius erato ssp. lativitta dorsal jpg 40315 dorsal \n", "346 Heliconius erato ssp. lativitta dorsal jpg 40544 dorsal \n", "278 Heliconius erato ssp. lativitta ventral jpg 40474 ventral \n", "180 Heliconius erato ssp. lativitta ventral jpg 40377 ventral \n", "176 Heliconius erato ssp. lativitta dorsal jpg 40371 dorsal \n", "103 Heliconius erato ssp. lativitta ventral jpg 40297 ventral \n", "74 Heliconius erato ssp. lativitta dorsal jpg 40267 dorsal \n", "186 Heliconius erato ssp. lativitta dorsal jpg 40379 dorsal \n", "283 Heliconius erato ssp. lativitta dorsal jpg 40476 dorsal \n", "\n", " mismatched_view \n", "276 False \n", "121 False \n", "346 False \n", "278 False \n", "180 False \n", "176 False \n", "103 False \n", "74 False \n", "186 False \n", "283 False " ] }, "execution_count": 134, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mismatched_view_cams = list(view_check.loc[view_check[\"mismatched_view\"], \"CAMID\"].unique())\n", "view_check.loc[(view_check[\"CAMID\"].isin(mismatched_view_cams)) & (view_check[\"file_type\"] == \"jpg\")].sample(10)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "OK, it _seems_ that it was just the raw photos that were mislabeled. We'll keep those updates." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "From this sample, it looks like record 42 fixed some mislabels from record 28. Should probably check if record 3477891 fixed mislabeling from the earlier records that it duplicated." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check Record 3477891 Duplicates" ] }, { "cell_type": "code", "execution_count": 119, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "CAMID 2704\n", "Image_name 5497\n", "X 10998\n", "filename 10998\n", "md5 5497\n", "file_url 5497\n", "dtype: int64" ] }, "execution_count": 119, "metadata": {}, "output_type": "execute_result" } ], "source": [ "md5s_3477891 = list(master_checksums.loc[master_checksums[\"record_number\"] == 3477891, \"md5\"].unique())\n", "patch_dupes = master_checksums.loc[master_checksums[\"md5\"].isin(md5s_3477891)]\n", "patch_dupes[id_cols].nunique()" ] }, { "cell_type": "code", "execution_count": 120, "metadata": {}, "outputs": [], "source": [ "patch_df = patch_dupes.loc[patch_dupes[\"record_number\"] == 3477891]\n", "patch_matches = patch_dupes.loc[patch_dupes[\"record_number\"] != 3477891]" ] }, { "cell_type": "code", "execution_count": 121, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CAMID 5501\n", "X 0\n", "Image_name 5501\n", "View 5495\n", "zenodo_name 0\n", "zenodo_link 0\n", "Sequence 5501\n", "Taxonomic_Name 5501\n", "Locality 5501\n", "Sample_accession 5501\n", "Other_ID 5501\n", "Date 5501\n", "Dataset 5501\n", "Store 5501\n", "Brood 5501\n", "Sex 5501\n", "Unit_Type 5501\n", "file_type 5501\n", "record_number 0\n", "species 5501\n", "subspecies 5501\n", "genus 5501\n", "file_url 5501\n", "hybrid_stat 5501\n", "filename 0\n", "filepath 0\n", "md5 5501\n" ] } ], "source": [ "patch_non_null_cols = [col for col in list(patch_dupes.columns)[:-1] if (patch_dupes.loc[patch_dupes[col].notna()].shape[0] > 0)]\n", "for col in patch_non_null_cols:\n", " merge_on = [\"md5\", col]\n", " temp = pd.merge(patch_df,\n", " patch_matches,\n", " on = merge_on,\n", " how = \"inner\")\n", " print(col, temp.shape[0])\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We again have the only inconsistency in the `View` column, where they do not align exactly (though it's only 6 differences)." ] }, { "cell_type": "code", "execution_count": 122, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(5501, 8)\n" ] }, { "data": { "text/plain": [ "mismatched_view\n", "False 5495\n", "True 6\n", "Name: count, dtype: int64" ] }, "execution_count": 122, "metadata": {}, "output_type": "execute_result" } ], "source": [ "patch_view_check = pd.merge(patch_matches[view_check_cols],\n", " patch_df[view_check_cols],\n", " on = [\"Image_name\", \"CAMID\", \"md5\", \"Taxonomic_Name\"],\n", " suffixes = (\"_old\", \"_patch\"),\n", " how = \"inner\")\n", "\n", "print(patch_view_check.shape)\n", "\n", "patch_view_check[\"mismatched_view\"] = patch_view_check[\"View_old\"] != patch_view_check[\"View_patch\"]\n", "patch_view_check[\"mismatched_view\"].value_counts()" ] }, { "cell_type": "code", "execution_count": 123, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_oldImage_nameCAMIDmd5Taxonomic_NameView_oldX_patchView_patchmismatched_view
168926075DSC_0697.jpgCAM008523764c722faeefa48aed09aef1956738a8Heliconius timareta ssp. timaretaventral49955dorsalTrue
1871260598624-UND.jpgCAM0086244a3b6c97a131436f3e5f95b0ef7695d2Heliconius timareta ssp. thelxinoeventral44341dorsalTrue
1880260618628-UND.jpgCAM00862897fdfb3de2e4a34f1c243056348962c5Heliconius timareta ssp. thelxinoeventral44342dorsalTrue
1886260638631-UND.jpgCAM008631e1c82f4e814c7a6c56ebc34b0f502298Heliconius timareta ssp. thelxinoeventral44343dorsalTrue
2516260669117_H_m_ecuadorensis_V.JPG.jpgCAM00911766a8b638d961955d3cd168c3168667edHeliconius melpomene ssp. ecuadorensisventral44375dorsalTrue
2531260689121_H_m_ecuadorensis_V.JPG.jpgCAM009121a14ff471e6be6c26bc2c0d8409a7a1e0Heliconius melpomene ssp. ecuadorensisventral44379dorsalTrue
\n", "
" ], "text/plain": [ " X_old Image_name CAMID \\\n", "1689 26075 DSC_0697.jpg CAM008523 \n", "1871 26059 8624-UND.jpg CAM008624 \n", "1880 26061 8628-UND.jpg CAM008628 \n", "1886 26063 8631-UND.jpg CAM008631 \n", "2516 26066 9117_H_m_ecuadorensis_V.JPG.jpg CAM009117 \n", "2531 26068 9121_H_m_ecuadorensis_V.JPG.jpg CAM009121 \n", "\n", " md5 \\\n", "1689 764c722faeefa48aed09aef1956738a8 \n", "1871 4a3b6c97a131436f3e5f95b0ef7695d2 \n", "1880 97fdfb3de2e4a34f1c243056348962c5 \n", "1886 e1c82f4e814c7a6c56ebc34b0f502298 \n", "2516 66a8b638d961955d3cd168c3168667ed \n", "2531 a14ff471e6be6c26bc2c0d8409a7a1e0 \n", "\n", " Taxonomic_Name View_old X_patch View_patch \\\n", "1689 Heliconius timareta ssp. timareta ventral 49955 dorsal \n", "1871 Heliconius timareta ssp. thelxinoe ventral 44341 dorsal \n", "1880 Heliconius timareta ssp. thelxinoe ventral 44342 dorsal \n", "1886 Heliconius timareta ssp. thelxinoe ventral 44343 dorsal \n", "2516 Heliconius melpomene ssp. ecuadorensis ventral 44375 dorsal \n", "2531 Heliconius melpomene ssp. ecuadorensis ventral 44379 dorsal \n", "\n", " mismatched_view \n", "1689 True \n", "1871 True \n", "1880 True \n", "1886 True \n", "2516 True \n", "2531 True " ] }, "execution_count": 123, "metadata": {}, "output_type": "execute_result" } ], "source": [ "patch_view_check.loc[patch_view_check[\"mismatched_view\"]]" ] }, { "cell_type": "code", "execution_count": 128, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
X_oldImage_nameCAMIDmd5Taxonomic_NameView_oldX_patchView_patchmismatched_viewmd5_dupe
2516260669117_H_m_ecuadorensis_V.JPG.jpgCAM00911766a8b638d961955d3cd168c3168667edHeliconius melpomene ssp. ecuadorensisventral44375dorsalTrueTrue
2517260669117_H_m_ecuadorensis_V.JPG.jpgCAM00911766a8b638d961955d3cd168c3168667edHeliconius melpomene ssp. ecuadorensisventral44374ventralFalseTrue
2519260659117_H_m_ecuadorensis_D.JPG.jpgCAM009117d10fcc5232e4c994d32e8181cb6e71e1Heliconius melpomene ssp. ecuadorensisdorsal44372dorsalFalseTrue
2520260659117_H_m_ecuadorensis_D.JPG.jpgCAM009117d10fcc5232e4c994d32e8181cb6e71e1Heliconius melpomene ssp. ecuadorensisdorsal44373dorsalFalseTrue
2529260679121_H_m_ecuadorensis_D.JPG.jpgCAM009121d53b79f77d12e7da1eb2ddf17418de9cHeliconius melpomene ssp. ecuadorensisdorsal44376dorsalFalseTrue
2530260679121_H_m_ecuadorensis_D.JPG.jpgCAM009121d53b79f77d12e7da1eb2ddf17418de9cHeliconius melpomene ssp. ecuadorensisdorsal44377dorsalFalseTrue
2531260689121_H_m_ecuadorensis_V.JPG.jpgCAM009121a14ff471e6be6c26bc2c0d8409a7a1e0Heliconius melpomene ssp. ecuadorensisventral44379dorsalTrueTrue
2532260689121_H_m_ecuadorensis_V.JPG.jpgCAM009121a14ff471e6be6c26bc2c0d8409a7a1e0Heliconius melpomene ssp. ecuadorensisventral44378ventralFalseTrue
\n", "
" ], "text/plain": [ " X_old Image_name CAMID \\\n", "2516 26066 9117_H_m_ecuadorensis_V.JPG.jpg CAM009117 \n", "2517 26066 9117_H_m_ecuadorensis_V.JPG.jpg CAM009117 \n", "2519 26065 9117_H_m_ecuadorensis_D.JPG.jpg CAM009117 \n", "2520 26065 9117_H_m_ecuadorensis_D.JPG.jpg CAM009117 \n", "2529 26067 9121_H_m_ecuadorensis_D.JPG.jpg CAM009121 \n", "2530 26067 9121_H_m_ecuadorensis_D.JPG.jpg CAM009121 \n", "2531 26068 9121_H_m_ecuadorensis_V.JPG.jpg CAM009121 \n", "2532 26068 9121_H_m_ecuadorensis_V.JPG.jpg CAM009121 \n", "\n", " md5 \\\n", "2516 66a8b638d961955d3cd168c3168667ed \n", "2517 66a8b638d961955d3cd168c3168667ed \n", "2519 d10fcc5232e4c994d32e8181cb6e71e1 \n", "2520 d10fcc5232e4c994d32e8181cb6e71e1 \n", "2529 d53b79f77d12e7da1eb2ddf17418de9c \n", "2530 d53b79f77d12e7da1eb2ddf17418de9c \n", "2531 a14ff471e6be6c26bc2c0d8409a7a1e0 \n", "2532 a14ff471e6be6c26bc2c0d8409a7a1e0 \n", "\n", " Taxonomic_Name View_old X_patch View_patch \\\n", "2516 Heliconius melpomene ssp. ecuadorensis ventral 44375 dorsal \n", "2517 Heliconius melpomene ssp. ecuadorensis ventral 44374 ventral \n", "2519 Heliconius melpomene ssp. ecuadorensis dorsal 44372 dorsal \n", "2520 Heliconius melpomene ssp. ecuadorensis dorsal 44373 dorsal \n", "2529 Heliconius melpomene ssp. ecuadorensis dorsal 44376 dorsal \n", "2530 Heliconius melpomene ssp. ecuadorensis dorsal 44377 dorsal \n", "2531 Heliconius melpomene ssp. ecuadorensis ventral 44379 dorsal \n", "2532 Heliconius melpomene ssp. ecuadorensis ventral 44378 ventral \n", "\n", " mismatched_view md5_dupe \n", "2516 True True \n", "2517 False True \n", "2519 False True \n", "2520 False True \n", "2529 False True \n", "2530 False True \n", "2531 True True \n", "2532 False True " ] }, "execution_count": 128, "metadata": {}, "output_type": "execute_result" } ], "source": [ "patch_view_check[\"md5_dupe\"] = patch_view_check.duplicated(\"md5\", keep = False)\n", "patch_view_check.loc[patch_view_check[\"md5_dupe\"]]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Manual check and confirmation with Christopher suggests that the additions (and duplications) were mislabled, so we will be proceeding without the patch." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Check the final Non-patch duplicates\n", "Those not in records `4291095, 2813153`:\n", "```\n", "5526257 20\n", "2553977 8\n", "2552371 2\n", "```" ] }, { "cell_type": "code", "execution_count": 135, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "15" ] }, "execution_count": 135, "metadata": {}, "output_type": "execute_result" } ], "source": [ "small_overlap = no_patch_duplicates.loc[~no_patch_duplicates[\"record_number\"].isin([4291095, 2813153])]\n", "small_overlap.md5.nunique()" ] }, { "cell_type": "code", "execution_count": 137, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...record_numberspeciessubspeciesgenusfile_urlhybrid_statfilenamefilepathmd5duplicate_md5
11978CAM0103542347110354d.jpgdorsalHeliconius_wing_old_photos_2001_2019_part1.csvhttps://zenodo.org/record/255237110,354Heliconius sp.NaNNaN...2552371Heliconius sp.NaNHeliconiushttps://zenodo.org/record/2552371/files/10354d...NaN23471_10354d.jpgimages/Heliconius sp./23471_10354d.jpg84d4ac6527458786cdb33166cd80e0a8True
12010CAM0103622348410362v.jpgventralHeliconius_wing_old_photos_2001_2019_part1.csvhttps://zenodo.org/record/255237110,362Heliconius sp.NaNNaN...2552371Heliconius sp.NaNHeliconiushttps://zenodo.org/record/2552371/files/10362v...NaN23484_10362v.jpgimages/Heliconius sp./23484_10362v.jpg84d4ac6527458786cdb33166cd80e0a8True
40112CAM05003626102CAM050036_S1_9_FW_IMG_8547_wb_2.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,036Heliconius sara ssp. saraGamboa_insectariesNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tifimages/Heliconius sara ssp. sara/26102_CAM0500...34adbd5596f977834fb2c6876d2f4493True
40113CAM05003626105CAM050036_S1_9_HW_wt_IMG_8541_cut3.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,036Heliconius sara ssp. saraGamboa_insectariesNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tifimages/Heliconius sara ssp. sara/26105_CAM0500...6d63d659fbc02369010938bbc229ad4dTrue
40116CAM05003626115CAM050036_S1_9_FW_IMG_8547_cut_2.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,036Heliconius sara ssp. saraGamboa_insectariesNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tifimages/Heliconius sara ssp. sara/26115_CAM0500...34adbd5596f977834fb2c6876d2f4493True
40120CAM05003626116CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,036Heliconius sara ssp. saraGamboa_insectariesNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tifimages/Heliconius sara ssp. sara/26116_CAM0500...6d63d659fbc02369010938bbc229ad4dTrue
40138CAM05014726112CAM050147_DS1_IMG_8513_4.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,147Heliconius sara ssp. saraMadingleyNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26112_CAM050147_DS1_IMG_8513_4.tifimages/Heliconius sara ssp. sara/26112_CAM0501...464801449aa127933d9619cb4e6f0a01True
40141CAM05014726197CAM050147_DS1_HW_IMG_8537_cut_3.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,147Heliconius sara ssp. saraMadingleyNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26197_CAM050147_DS1_HW_IMG_8537_cut_3.tifimages/Heliconius sara ssp. sara/26197_CAM0501...21e726df7076f5c13fe1441126bac4d5True
40144CAM05014726196CAM050147_DS1_HW_IMG_8537_cut_3.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,147Heliconius sara ssp. saraMadingleyNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26196_CAM050147_DS1_HW_IMG_8537_cut_3.tifimages/Heliconius sara ssp. sara/26196_CAM0501...21e726df7076f5c13fe1441126bac4d5True
40145CAM05014726117CAM050147_DS1_FW_IMG_8513_cut_4.tifdorsalHeliconius_wing_old_photos_2001_2019_part3.csvhttps://zenodo.org/record/255397750,147Heliconius sara ssp. saraMadingleyNaN...2553977Heliconius sarasaraHeliconiushttps://zenodo.org/record/2553977/files/CAM050...non-hybrid26117_CAM050147_DS1_FW_IMG_8513_cut_4.tifimages/Heliconius sara ssp. sara/26117_CAM0501...464801449aa127933d9619cb4e6f0a01True
\n", "

10 rows × 32 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View \\\n", "11978 CAM010354 23471 10354d.jpg dorsal \n", "12010 CAM010362 23484 10362v.jpg ventral \n", "40112 CAM050036 26102 CAM050036_S1_9_FW_IMG_8547_wb_2.tif dorsal \n", "40113 CAM050036 26105 CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif dorsal \n", "40116 CAM050036 26115 CAM050036_S1_9_FW_IMG_8547_cut_2.tif dorsal \n", "40120 CAM050036 26116 CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif dorsal \n", "40138 CAM050147 26112 CAM050147_DS1_IMG_8513_4.tif dorsal \n", "40141 CAM050147 26197 CAM050147_DS1_HW_IMG_8537_cut_3.tif dorsal \n", "40144 CAM050147 26196 CAM050147_DS1_HW_IMG_8537_cut_3.tif dorsal \n", "40145 CAM050147 26117 CAM050147_DS1_FW_IMG_8513_cut_4.tif dorsal \n", "\n", " zenodo_name \\\n", "11978 Heliconius_wing_old_photos_2001_2019_part1.csv \n", "12010 Heliconius_wing_old_photos_2001_2019_part1.csv \n", "40112 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40113 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40116 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40120 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40138 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40141 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40144 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "40145 Heliconius_wing_old_photos_2001_2019_part3.csv \n", "\n", " zenodo_link Sequence Taxonomic_Name \\\n", "11978 https://zenodo.org/record/2552371 10,354 Heliconius sp. \n", "12010 https://zenodo.org/record/2552371 10,362 Heliconius sp. \n", "40112 https://zenodo.org/record/2553977 50,036 Heliconius sara ssp. sara \n", "40113 https://zenodo.org/record/2553977 50,036 Heliconius sara ssp. sara \n", "40116 https://zenodo.org/record/2553977 50,036 Heliconius sara ssp. sara \n", "40120 https://zenodo.org/record/2553977 50,036 Heliconius sara ssp. sara \n", "40138 https://zenodo.org/record/2553977 50,147 Heliconius sara ssp. sara \n", "40141 https://zenodo.org/record/2553977 50,147 Heliconius sara ssp. sara \n", "40144 https://zenodo.org/record/2553977 50,147 Heliconius sara ssp. sara \n", "40145 https://zenodo.org/record/2553977 50,147 Heliconius sara ssp. sara \n", "\n", " Locality Sample_accession ... record_number \\\n", "11978 NaN NaN ... 2552371 \n", "12010 NaN NaN ... 2552371 \n", "40112 Gamboa_insectaries NaN ... 2553977 \n", "40113 Gamboa_insectaries NaN ... 2553977 \n", "40116 Gamboa_insectaries NaN ... 2553977 \n", "40120 Gamboa_insectaries NaN ... 2553977 \n", "40138 Madingley NaN ... 2553977 \n", "40141 Madingley NaN ... 2553977 \n", "40144 Madingley NaN ... 2553977 \n", "40145 Madingley NaN ... 2553977 \n", "\n", " species subspecies genus \\\n", "11978 Heliconius sp. NaN Heliconius \n", "12010 Heliconius sp. NaN Heliconius \n", "40112 Heliconius sara sara Heliconius \n", "40113 Heliconius sara sara Heliconius \n", "40116 Heliconius sara sara Heliconius \n", "40120 Heliconius sara sara Heliconius \n", "40138 Heliconius sara sara Heliconius \n", "40141 Heliconius sara sara Heliconius \n", "40144 Heliconius sara sara Heliconius \n", "40145 Heliconius sara sara Heliconius \n", "\n", " file_url hybrid_stat \\\n", "11978 https://zenodo.org/record/2552371/files/10354d... NaN \n", "12010 https://zenodo.org/record/2552371/files/10362v... NaN \n", "40112 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40113 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40116 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40120 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40138 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40141 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40144 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "40145 https://zenodo.org/record/2553977/files/CAM050... non-hybrid \n", "\n", " filename \\\n", "11978 23471_10354d.jpg \n", "12010 23484_10362v.jpg \n", "40112 26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif \n", "40113 26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif \n", "40116 26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif \n", "40120 26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif \n", "40138 26112_CAM050147_DS1_IMG_8513_4.tif \n", "40141 26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif \n", "40144 26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif \n", "40145 26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif \n", "\n", " filepath \\\n", "11978 images/Heliconius sp./23471_10354d.jpg \n", "12010 images/Heliconius sp./23484_10362v.jpg \n", "40112 images/Heliconius sara ssp. sara/26102_CAM0500... \n", "40113 images/Heliconius sara ssp. sara/26105_CAM0500... \n", "40116 images/Heliconius sara ssp. sara/26115_CAM0500... \n", "40120 images/Heliconius sara ssp. sara/26116_CAM0500... \n", "40138 images/Heliconius sara ssp. sara/26112_CAM0501... \n", "40141 images/Heliconius sara ssp. sara/26197_CAM0501... \n", "40144 images/Heliconius sara ssp. sara/26196_CAM0501... \n", "40145 images/Heliconius sara ssp. sara/26117_CAM0501... \n", "\n", " md5 duplicate_md5 \n", "11978 84d4ac6527458786cdb33166cd80e0a8 True \n", "12010 84d4ac6527458786cdb33166cd80e0a8 True \n", "40112 34adbd5596f977834fb2c6876d2f4493 True \n", "40113 6d63d659fbc02369010938bbc229ad4d True \n", "40116 34adbd5596f977834fb2c6876d2f4493 True \n", "40120 6d63d659fbc02369010938bbc229ad4d True \n", "40138 464801449aa127933d9619cb4e6f0a01 True \n", "40141 21e726df7076f5c13fe1441126bac4d5 True \n", "40144 21e726df7076f5c13fe1441126bac4d5 True \n", "40145 464801449aa127933d9619cb4e6f0a01 True \n", "\n", "[10 rows x 32 columns]" ] }, "execution_count": 137, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#check smallest two for overlap\n", "small_overlap.loc[small_overlap[\"record_number\"].isin([2553977, 2552371])]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These do not seem to overlap. Instead, they seem to duplicate within each record.\n", "\n", "Likely there is duplication introduced also in record 5526257." ] }, { "cell_type": "code", "execution_count": 139, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Record 5526257 uniqueness: 10\n", "Records 255.. uniqueness: 5\n" ] } ], "source": [ "rec_55 = small_overlap.loc[small_overlap[\"record_number\"] == 5526257]\n", "recs_255 = small_overlap.loc[small_overlap[\"record_number\"].isin([2553977, 2552371])]\n", "\n", "print(\"Record 5526257 uniqueness:\", rec_55.md5.nunique())\n", "print(\"Records 255.. uniqueness:\", recs_255.md5.nunique())" ] }, { "cell_type": "code", "execution_count": 140, "metadata": {}, "outputs": [], "source": [ "columns_55 = [\"CAMID\", \"filename\", \"View\", \"Taxonomic_Name\", \"Locality\", \"md5\"]" ] }, { "cell_type": "code", "execution_count": 142, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDfilenameViewTaxonomic_NameLocalitymd5
38765CAM04500942597_CAM045009_d.CR2dorsalHeliconius erato ssp. cyrbiaNaN3aa4f36fe82bf582cdb09e22cf998ea0
38764CAM04500942596_CAM045009_d.CR2dorsalHeliconius erato ssp. cyrbiaNaN3aa4f36fe82bf582cdb09e22cf998ea0
39189CAM04511443024_CAM045114_v.JPGventralHeliconius erato ssp. cyrbiaNaN46264ce1e0e5bd93735534c8cdc3a9fb
39193CAM04511443025_CAM045114_v.JPGventralHeliconius erato ssp. cyrbiaNaN46264ce1e0e5bd93735534c8cdc3a9fb
38755CAM04500642587_CAM045006_v.CR2ventralHeliconius erato ssp. cyrbiaNaN5c71b211545b1b469dfadb06b35ccd57
38750CAM04500642586_CAM045006_v.CR2ventralHeliconius erato ssp. cyrbiaNaN5c71b211545b1b469dfadb06b35ccd57
38770CAM04500942602_CAM045009_v.JPGventralHeliconius erato ssp. cyrbiaNaN6e1c1b698bbafe5fe686c00f93991759
38771CAM04500942603_CAM045009_v.JPGventralHeliconius erato ssp. cyrbiaNaN6e1c1b698bbafe5fe686c00f93991759
38754CAM04500642585_CAM045006_d.JPGdorsalHeliconius erato ssp. cyrbiaNaN7f09b3de42a6771d0ac63bee6995bc49
38753CAM04500642584_CAM045006_d.JPGdorsalHeliconius erato ssp. cyrbiaNaN7f09b3de42a6771d0ac63bee6995bc49
38752CAM04500642583_CAM045006_d.CR2dorsalHeliconius erato ssp. cyrbiaNaNb146797ff261debef1f8ae93ce528817
38751CAM04500642582_CAM045006_d.CR2dorsalHeliconius erato ssp. cyrbiaNaNb146797ff261debef1f8ae93ce528817
38766CAM04500942598_CAM045009_d.JPGdorsalHeliconius erato ssp. cyrbiaNaNbd26f12f1fb204c623ff9fd615d6a0fd
38767CAM04500942599_CAM045009_d.JPGdorsalHeliconius erato ssp. cyrbiaNaNbd26f12f1fb204c623ff9fd615d6a0fd
39192CAM04511443023_CAM045114_v.CR2ventralHeliconius erato ssp. cyrbiaNaNdb4c1d373140cd4e56f0976a88b0ab54
39191CAM04511443022_CAM045114_v.CR2ventralHeliconius erato ssp. cyrbiaNaNdb4c1d373140cd4e56f0976a88b0ab54
38768CAM04500942600_CAM045009_v.CR2ventralHeliconius erato ssp. cyrbiaNaNe9acf59ae9d96564f5cd8342281e4514
38769CAM04500942601_CAM045009_v.CR2ventralHeliconius erato ssp. cyrbiaNaNe9acf59ae9d96564f5cd8342281e4514
38756CAM04500642588_CAM045006_v.JPGventralHeliconius erato ssp. cyrbiaNaNf64512f4ce131775f3594e96ba761fa9
38757CAM04500642589_CAM045006_v.JPGventralHeliconius erato ssp. cyrbiaNaNf64512f4ce131775f3594e96ba761fa9
\n", "
" ], "text/plain": [ " CAMID filename View \\\n", "38765 CAM045009 42597_CAM045009_d.CR2 dorsal \n", "38764 CAM045009 42596_CAM045009_d.CR2 dorsal \n", "39189 CAM045114 43024_CAM045114_v.JPG ventral \n", "39193 CAM045114 43025_CAM045114_v.JPG ventral \n", "38755 CAM045006 42587_CAM045006_v.CR2 ventral \n", "38750 CAM045006 42586_CAM045006_v.CR2 ventral \n", "38770 CAM045009 42602_CAM045009_v.JPG ventral \n", "38771 CAM045009 42603_CAM045009_v.JPG ventral \n", "38754 CAM045006 42585_CAM045006_d.JPG dorsal \n", "38753 CAM045006 42584_CAM045006_d.JPG dorsal \n", "38752 CAM045006 42583_CAM045006_d.CR2 dorsal \n", "38751 CAM045006 42582_CAM045006_d.CR2 dorsal \n", "38766 CAM045009 42598_CAM045009_d.JPG dorsal \n", "38767 CAM045009 42599_CAM045009_d.JPG dorsal \n", "39192 CAM045114 43023_CAM045114_v.CR2 ventral \n", "39191 CAM045114 43022_CAM045114_v.CR2 ventral \n", "38768 CAM045009 42600_CAM045009_v.CR2 ventral \n", "38769 CAM045009 42601_CAM045009_v.CR2 ventral \n", "38756 CAM045006 42588_CAM045006_v.JPG ventral \n", "38757 CAM045006 42589_CAM045006_v.JPG ventral \n", "\n", " Taxonomic_Name Locality md5 \n", "38765 Heliconius erato ssp. cyrbia NaN 3aa4f36fe82bf582cdb09e22cf998ea0 \n", "38764 Heliconius erato ssp. cyrbia NaN 3aa4f36fe82bf582cdb09e22cf998ea0 \n", "39189 Heliconius erato ssp. cyrbia NaN 46264ce1e0e5bd93735534c8cdc3a9fb \n", "39193 Heliconius erato ssp. cyrbia NaN 46264ce1e0e5bd93735534c8cdc3a9fb \n", "38755 Heliconius erato ssp. cyrbia NaN 5c71b211545b1b469dfadb06b35ccd57 \n", "38750 Heliconius erato ssp. cyrbia NaN 5c71b211545b1b469dfadb06b35ccd57 \n", "38770 Heliconius erato ssp. cyrbia NaN 6e1c1b698bbafe5fe686c00f93991759 \n", "38771 Heliconius erato ssp. cyrbia NaN 6e1c1b698bbafe5fe686c00f93991759 \n", "38754 Heliconius erato ssp. cyrbia NaN 7f09b3de42a6771d0ac63bee6995bc49 \n", "38753 Heliconius erato ssp. cyrbia NaN 7f09b3de42a6771d0ac63bee6995bc49 \n", "38752 Heliconius erato ssp. cyrbia NaN b146797ff261debef1f8ae93ce528817 \n", "38751 Heliconius erato ssp. cyrbia NaN b146797ff261debef1f8ae93ce528817 \n", "38766 Heliconius erato ssp. cyrbia NaN bd26f12f1fb204c623ff9fd615d6a0fd \n", "38767 Heliconius erato ssp. cyrbia NaN bd26f12f1fb204c623ff9fd615d6a0fd \n", "39192 Heliconius erato ssp. cyrbia NaN db4c1d373140cd4e56f0976a88b0ab54 \n", "39191 Heliconius erato ssp. cyrbia NaN db4c1d373140cd4e56f0976a88b0ab54 \n", "38768 Heliconius erato ssp. cyrbia NaN e9acf59ae9d96564f5cd8342281e4514 \n", "38769 Heliconius erato ssp. cyrbia NaN e9acf59ae9d96564f5cd8342281e4514 \n", "38756 Heliconius erato ssp. cyrbia NaN f64512f4ce131775f3594e96ba761fa9 \n", "38757 Heliconius erato ssp. cyrbia NaN f64512f4ce131775f3594e96ba761fa9 " ] }, "execution_count": 142, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_55[columns_55].sort_values(by = \"md5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These are all exact duplicates..." ] }, { "cell_type": "code", "execution_count": 143, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "False 10\n", "True 10\n", "Name: count, dtype: int64" ] }, "execution_count": 143, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rec_55.duplicated([\"CAMID\", \"Image_name\", \"View\", \"Taxonomic_Name\", \"Locality\", \"md5\"], keep = \"first\").value_counts()" ] }, { "cell_type": "code", "execution_count": 148, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
CAMIDfilenameViewTaxonomic_NameLocalitymd5
40141CAM05014726197_CAM050147_DS1_HW_IMG_8537_cut_3.tifdorsalHeliconius sara ssp. saraMadingley21e726df7076f5c13fe1441126bac4d5
40144CAM05014726196_CAM050147_DS1_HW_IMG_8537_cut_3.tifdorsalHeliconius sara ssp. saraMadingley21e726df7076f5c13fe1441126bac4d5
40112CAM05003626102_CAM050036_S1_9_FW_IMG_8547_wb_2.tifdorsalHeliconius sara ssp. saraGamboa_insectaries34adbd5596f977834fb2c6876d2f4493
40116CAM05003626115_CAM050036_S1_9_FW_IMG_8547_cut_2.tifdorsalHeliconius sara ssp. saraGamboa_insectaries34adbd5596f977834fb2c6876d2f4493
40138CAM05014726112_CAM050147_DS1_IMG_8513_4.tifdorsalHeliconius sara ssp. saraMadingley464801449aa127933d9619cb4e6f0a01
40145CAM05014726117_CAM050147_DS1_FW_IMG_8513_cut_4.tifdorsalHeliconius sara ssp. saraMadingley464801449aa127933d9619cb4e6f0a01
40113CAM05003626105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tifdorsalHeliconius sara ssp. saraGamboa_insectaries6d63d659fbc02369010938bbc229ad4d
40120CAM05003626116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tifdorsalHeliconius sara ssp. saraGamboa_insectaries6d63d659fbc02369010938bbc229ad4d
11978CAM01035423471_10354d.jpgdorsalHeliconius sp.NaN84d4ac6527458786cdb33166cd80e0a8
12010CAM01036223484_10362v.jpgventralHeliconius sp.NaN84d4ac6527458786cdb33166cd80e0a8
\n", "
" ], "text/plain": [ " CAMID filename View \\\n", "40141 CAM050147 26197_CAM050147_DS1_HW_IMG_8537_cut_3.tif dorsal \n", "40144 CAM050147 26196_CAM050147_DS1_HW_IMG_8537_cut_3.tif dorsal \n", "40112 CAM050036 26102_CAM050036_S1_9_FW_IMG_8547_wb_2.tif dorsal \n", "40116 CAM050036 26115_CAM050036_S1_9_FW_IMG_8547_cut_2.tif dorsal \n", "40138 CAM050147 26112_CAM050147_DS1_IMG_8513_4.tif dorsal \n", "40145 CAM050147 26117_CAM050147_DS1_FW_IMG_8513_cut_4.tif dorsal \n", "40113 CAM050036 26105_CAM050036_S1_9_HW_wt_IMG_8541_cut3.tif dorsal \n", "40120 CAM050036 26116_CAM050036_S1_9_HW_wt_IMG_8541_cut_3.tif dorsal \n", "11978 CAM010354 23471_10354d.jpg dorsal \n", "12010 CAM010362 23484_10362v.jpg ventral \n", "\n", " Taxonomic_Name Locality \\\n", "40141 Heliconius sara ssp. sara Madingley \n", "40144 Heliconius sara ssp. sara Madingley \n", "40112 Heliconius sara ssp. sara Gamboa_insectaries \n", "40116 Heliconius sara ssp. sara Gamboa_insectaries \n", "40138 Heliconius sara ssp. sara Madingley \n", "40145 Heliconius sara ssp. sara Madingley \n", "40113 Heliconius sara ssp. sara Gamboa_insectaries \n", "40120 Heliconius sara ssp. sara Gamboa_insectaries \n", "11978 Heliconius sp. NaN \n", "12010 Heliconius sp. NaN \n", "\n", " md5 \n", "40141 21e726df7076f5c13fe1441126bac4d5 \n", "40144 21e726df7076f5c13fe1441126bac4d5 \n", "40112 34adbd5596f977834fb2c6876d2f4493 \n", "40116 34adbd5596f977834fb2c6876d2f4493 \n", "40138 464801449aa127933d9619cb4e6f0a01 \n", "40145 464801449aa127933d9619cb4e6f0a01 \n", "40113 6d63d659fbc02369010938bbc229ad4d \n", "40120 6d63d659fbc02369010938bbc229ad4d \n", "11978 84d4ac6527458786cdb33166cd80e0a8 \n", "12010 84d4ac6527458786cdb33166cd80e0a8 " ] }, "execution_count": 148, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recs_255[columns_55].sort_values(by = \"md5\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These have mismatched filenames and even mismatched CAMIDs for record 2552371.\n", "\n", "The first 8 are all cropped close-ups of a single wing, so don't seem particularly helpful for our use-cases. Will keep the ones with `cut_` in the name, as some of this duplication seems to be from errors in image naming (the view also is inconsistent since it's a crop of a single wing).\n", "\n", "The last two are unspecified species. The image is definitely dorsal, but there is no indication of which specimen it is, so both records must be removed." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "std", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.3" } }, "nbformat": 4, "nbformat_minor": 2 }