{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import json" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "RangeIndex: 50 entries, 0 to 49\n", "Data columns (total 4 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 File name 50 non-null object\n", " 1 ID 49 non-null object\n", " 2 Side 49 non-null object\n", " 3 Unnamed: 3 49 non-null object\n", "dtypes: object(4)\n", "memory usage: 1.7+ KB\n" ] } ], "source": [ "# Record 4289223 is most of our initial 404s (ultimately just second most), \n", "# looks like they align with 0.2.rachel.blow.mel.tim.ikiam.csv, so we'll check\n", "fof_df = pd.read_csv(\"../metadata/deduplication/Zenodo_meta_files/0.2.rachel.blow.mel.tim.ikiam.csv\", low_memory = False)\n", "fof_df.info(show_counts=True)" ] }, { "cell_type": "code", "execution_count": 3, "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", "
File nameIDSideUnnamed: 3
0CAM028501d.JPGCAM028501dorsald.JPG
1CAM028501v.JPGCAM028501ventralv.JPG
2CAM028502d.JPGCAM028502dorsald.JPG
3CAM028502v.JPGCAM028502ventralv.JPG
4CAM028503d.JPGCAM028503dorsald.JPG
\n", "
" ], "text/plain": [ " File name ID Side Unnamed: 3\n", "0 CAM028501d.JPG CAM028501 dorsal d.JPG\n", "1 CAM028501v.JPG CAM028501 ventral v.JPG\n", "2 CAM028502d.JPG CAM028502 dorsal d.JPG\n", "3 CAM028502v.JPG CAM028502 ventral v.JPG\n", "4 CAM028503d.JPG CAM028503 dorsal d.JPG" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fof_df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These don't have a URL, but it could be reconstructed from the record number. Let's check if these are the files that had the 404 error from that record." ] }, { "cell_type": "code", "execution_count": 4, "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", "
Imagefile_urlrecord_numberdatasetCAMIDResponse_status
0Heliconius melpomene ssp. plesseni x malleti/5...https://zenodo.org/record/3082688/files/CAM017...3082688Patricio SalazarCAM017505404
1Heliconius erato ssp. notabilis x lativitta/54...https://zenodo.org/record/3082688/files/CAM017...3082688Patricio SalazarCAM017693404
2Heliconius erato ssp. notabilis x lativitta/55...https://zenodo.org/record/3082688/files/CAM017...3082688Patricio SalazarCAM017821404
3Heliconius melpomene ssp. plesseni x malleti/1...https://zenodo.org/record/1748277/files/CAM017...1748277Patricio SalazarCAM017932404
4Heliconius melpomene ssp. plesseni x malleti/1...https://zenodo.org/record/1748277/files/CAM017...1748277Patricio SalazarCAM017971404
\n", "
" ], "text/plain": [ " Image \\\n", "0 Heliconius melpomene ssp. plesseni x malleti/5... \n", "1 Heliconius erato ssp. notabilis x lativitta/54... \n", "2 Heliconius erato ssp. notabilis x lativitta/55... \n", "3 Heliconius melpomene ssp. plesseni x malleti/1... \n", "4 Heliconius melpomene ssp. plesseni x malleti/1... \n", "\n", " file_url record_number \\\n", "0 https://zenodo.org/record/3082688/files/CAM017... 3082688 \n", "1 https://zenodo.org/record/3082688/files/CAM017... 3082688 \n", "2 https://zenodo.org/record/3082688/files/CAM017... 3082688 \n", "3 https://zenodo.org/record/1748277/files/CAM017... 1748277 \n", "4 https://zenodo.org/record/1748277/files/CAM017... 1748277 \n", "\n", " dataset CAMID Response_status \n", "0 Patricio Salazar CAM017505 404 \n", "1 Patricio Salazar CAM017693 404 \n", "2 Patricio Salazar CAM017821 404 \n", "3 Patricio Salazar CAM017932 404 \n", "4 Patricio Salazar CAM017971 404 " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ERROR_PATH = \"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_error_log_(readable).json\"\n", "with open(ERROR_PATH, \"r\") as error_file:\n", " errors = json.loads(error_file.read())\n", "\n", "error_df = pd.DataFrame(data = errors)\n", "error_df.head()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "23\n", "0\n" ] } ], "source": [ "rec_4289223_df = error_df.loc[error_df[\"record_number\"] == \"4289223\"]\n", "\n", "missing_camids = []\n", "for camid in list(rec_4289223_df[\"CAMID\"].unique()):\n", " if camid not in list(fof_df.ID):\n", " missing_camids.append(camid)\n", "\n", "print(rec_4289223_df.CAMID.nunique())\n", "print(len(missing_camids))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Looks like they're all captured in this CSV, so we can check their URLs?" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['https://zenodo.org/record/4289223/files/CAM028509v.JPG',\n", " 'https://zenodo.org/record/4289223/files/CAM028504d.JPG',\n", " 'https://zenodo.org/record/4289223/files/CAM028508v.JPG',\n", " 'https://zenodo.org/record/4289223/files/CAM028509d.JPG',\n", " 'https://zenodo.org/record/4289223/files/CAM028502v.JPG',\n", " 'https://zenodo.org/record/4289223/files/CAM028513v.CR2',\n", " 'https://zenodo.org/record/4289223/files/CAM028514d.JPG']" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "list(rec_4289223_df.file_url.sample(7))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "These are listed in the CSV, but do not show up on the [record page](https://zenodo.org/records/4289223)." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We saw in `EDA-DL-0-1.ipynb` that none of the error images were in the multimedia file from record 3477891, so we don't have a clear patch. All error records were saved to a CSV through that notebook." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Index(['Image', 'file_url', 'record_number', 'dataset', 'CAMID',\n", " 'Response_status', 'filename', 'view'],\n", " dtype='object')\n" ] } ], "source": [ "error_df = pd.read_csv(\"../metadata/deduplication/Jiggins_Zenodo_Img_Master_3477891Patch_error_log.csv\", low_memory = False)\n", "print(error_df.columns)\n", "\n", "master = pd.read_csv(\"../metadata/Jiggins_Zenodo_Img_Master_3477891Patch.csv\", low_memory = False)" ] }, { "cell_type": "code", "execution_count": 8, "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", "
Imagefile_urlrecord_numberdatasetCAMIDResponse_statusfilenameview
5Heliconius melpomene ssp. malleti/14972_CAM028...https://zenodo.org/record/4289223/files/CAM028...4289223Cambridge CollectionCAM02850140414972_CAM028501v.JPGventral
6Heliconius melpomene ssp. malleti/14971_CAM028...https://zenodo.org/record/4289223/files/CAM028...4289223Cambridge CollectionCAM02850140414971_CAM028501d.JPGdorsal
7Heliconius melpomene ssp. malleti/14973_CAM028...https://zenodo.org/record/4289223/files/CAM028...4289223Cambridge CollectionCAM02850240414973_CAM028502d.JPGdorsal
8Heliconius melpomene ssp. malleti/14974_CAM028...https://zenodo.org/record/4289223/files/CAM028...4289223Cambridge CollectionCAM02850240414974_CAM028502v.JPGventral
9Heliconius melpomene ssp. plesseni/14975_CAM02...https://zenodo.org/record/4289223/files/CAM028...4289223Cambridge CollectionCAM02850340414975_CAM028503d.JPGdorsal
\n", "
" ], "text/plain": [ " Image \\\n", "5 Heliconius melpomene ssp. malleti/14972_CAM028... \n", "6 Heliconius melpomene ssp. malleti/14971_CAM028... \n", "7 Heliconius melpomene ssp. malleti/14973_CAM028... \n", "8 Heliconius melpomene ssp. malleti/14974_CAM028... \n", "9 Heliconius melpomene ssp. plesseni/14975_CAM02... \n", "\n", " file_url record_number \\\n", "5 https://zenodo.org/record/4289223/files/CAM028... 4289223 \n", "6 https://zenodo.org/record/4289223/files/CAM028... 4289223 \n", "7 https://zenodo.org/record/4289223/files/CAM028... 4289223 \n", "8 https://zenodo.org/record/4289223/files/CAM028... 4289223 \n", "9 https://zenodo.org/record/4289223/files/CAM028... 4289223 \n", "\n", " dataset CAMID Response_status filename \\\n", "5 Cambridge Collection CAM028501 404 14972_CAM028501v.JPG \n", "6 Cambridge Collection CAM028501 404 14971_CAM028501d.JPG \n", "7 Cambridge Collection CAM028502 404 14973_CAM028502d.JPG \n", "8 Cambridge Collection CAM028502 404 14974_CAM028502v.JPG \n", "9 Cambridge Collection CAM028503 404 14975_CAM028503d.JPG \n", "\n", " view \n", "5 ventral \n", "6 dorsal \n", "7 dorsal \n", "8 ventral \n", "9 dorsal " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "error_42 = error_df.loc[error_df[\"record_number\"] == 4289223].copy()\n", "error_42.head()" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [], "source": [ "def get_x(filename):\n", " return int(filename.split(\"_\")[0])" ] }, { "cell_type": "code", "execution_count": 10, "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", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...StageSexUnit_Typefile_typerecord_numberspeciessubspeciesgenusfile_urlhybrid_stat
24194CAM02850114972CAM028501v.JPGventral0.2.rachel.blow.mel.tim.ikiam.csvhttps://zenodo.org/record/428922328,501Heliconius melpomene ssp. malletiRío PusunoNaN...NaNMaleWildjpg4289223Heliconius melpomenemalletiHeliconiushttps://zenodo.org/record/4289223/files/CAM028...non-hybrid
24195CAM02850114971CAM028501d.JPGdorsal0.2.rachel.blow.mel.tim.ikiam.csvhttps://zenodo.org/record/428922328,501Heliconius melpomene ssp. malletiRío PusunoNaN...NaNMaleWildjpg4289223Heliconius melpomenemalletiHeliconiushttps://zenodo.org/record/4289223/files/CAM028...non-hybrid
24196CAM02850214973CAM028502d.JPGdorsal0.2.rachel.blow.mel.tim.ikiam.csvhttps://zenodo.org/record/428922328,502Heliconius melpomene ssp. malletiRío PusunoNaN...NaNMaleWildjpg4289223Heliconius melpomenemalletiHeliconiushttps://zenodo.org/record/4289223/files/CAM028...non-hybrid
24197CAM02850214974CAM028502v.JPGventral0.2.rachel.blow.mel.tim.ikiam.csvhttps://zenodo.org/record/428922328,502Heliconius melpomene ssp. malletiRío PusunoNaN...NaNMaleWildjpg4289223Heliconius melpomenemalletiHeliconiushttps://zenodo.org/record/4289223/files/CAM028...non-hybrid
24198CAM02850314975CAM028503d.JPGdorsal0.2.rachel.blow.mel.tim.ikiam.csvhttps://zenodo.org/record/428922328,503Heliconius melpomene ssp. plesseniHuaymayacoNaN...NaNMaleWildjpg4289223Heliconius melpomeneplesseniHeliconiushttps://zenodo.org/record/4289223/files/CAM028...non-hybrid
\n", "

5 rows × 28 columns

\n", "
" ], "text/plain": [ " CAMID X Image_name View \\\n", "24194 CAM028501 14972 CAM028501v.JPG ventral \n", "24195 CAM028501 14971 CAM028501d.JPG dorsal \n", "24196 CAM028502 14973 CAM028502d.JPG dorsal \n", "24197 CAM028502 14974 CAM028502v.JPG ventral \n", "24198 CAM028503 14975 CAM028503d.JPG dorsal \n", "\n", " zenodo_name zenodo_link \\\n", "24194 0.2.rachel.blow.mel.tim.ikiam.csv https://zenodo.org/record/4289223 \n", "24195 0.2.rachel.blow.mel.tim.ikiam.csv https://zenodo.org/record/4289223 \n", "24196 0.2.rachel.blow.mel.tim.ikiam.csv https://zenodo.org/record/4289223 \n", "24197 0.2.rachel.blow.mel.tim.ikiam.csv https://zenodo.org/record/4289223 \n", "24198 0.2.rachel.blow.mel.tim.ikiam.csv https://zenodo.org/record/4289223 \n", "\n", " Sequence Taxonomic_Name Locality \\\n", "24194 28,501 Heliconius melpomene ssp. malleti Río Pusuno \n", "24195 28,501 Heliconius melpomene ssp. malleti Río Pusuno \n", "24196 28,502 Heliconius melpomene ssp. malleti Río Pusuno \n", "24197 28,502 Heliconius melpomene ssp. malleti Río Pusuno \n", "24198 28,503 Heliconius melpomene ssp. plesseni Huaymayaco \n", "\n", " Sample_accession ... Stage Sex Unit_Type file_type record_number \\\n", "24194 NaN ... NaN Male Wild jpg 4289223 \n", "24195 NaN ... NaN Male Wild jpg 4289223 \n", "24196 NaN ... NaN Male Wild jpg 4289223 \n", "24197 NaN ... NaN Male Wild jpg 4289223 \n", "24198 NaN ... NaN Male Wild jpg 4289223 \n", "\n", " species subspecies genus \\\n", "24194 Heliconius melpomene malleti Heliconius \n", "24195 Heliconius melpomene malleti Heliconius \n", "24196 Heliconius melpomene malleti Heliconius \n", "24197 Heliconius melpomene malleti Heliconius \n", "24198 Heliconius melpomene plesseni Heliconius \n", "\n", " file_url hybrid_stat \n", "24194 https://zenodo.org/record/4289223/files/CAM028... non-hybrid \n", "24195 https://zenodo.org/record/4289223/files/CAM028... non-hybrid \n", "24196 https://zenodo.org/record/4289223/files/CAM028... non-hybrid \n", "24197 https://zenodo.org/record/4289223/files/CAM028... non-hybrid \n", "24198 https://zenodo.org/record/4289223/files/CAM028... non-hybrid \n", "\n", "[5 rows x 28 columns]" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "error_42[\"X\"] = error_42[\"filename\"].apply(get_x)\n", "\n", "master_42 = master.loc[master[\"X\"].isin(list(error_42[\"X\"]))].copy()\n", "master_42.head()" ] }, { "cell_type": "code", "execution_count": 11, "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", "
CAMIDXImage_nameViewzenodo_namezenodo_linkSequenceTaxonomic_NameLocalitySample_accession...StageSexUnit_Typefile_typerecord_numberspeciessubspeciesgenusfile_urlhybrid_stat
\n", "

0 rows × 28 columns

\n", "
" ], "text/plain": [ "Empty DataFrame\n", "Columns: [CAMID, X, Image_name, View, zenodo_name, zenodo_link, Sequence, Taxonomic_Name, Locality, Sample_accession, Collected_by, Other_ID, Date, Dataset, Store, Brood, Death_Date, Cross_Type, Stage, Sex, Unit_Type, file_type, record_number, species, subspecies, genus, file_url, hybrid_stat]\n", "Index: []\n", "\n", "[0 rows x 28 columns]" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "master.loc[(master[\"Image_name\"].isin(list(master_42.Image_name.unique()))) & (~master[\"record_number\"] == 4289223)]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Can't align these elsewhere based on `Image_name` either." ] }, { "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 }