{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"name":"python","version":"3.10.13","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"},"kaggle":{"accelerator":"none","dataSources":[{"sourceId":73479,"databundleVersionId":8143437,"sourceType":"competition"}],"dockerImageVersionId":30673,"isInternetEnabled":true,"language":"python","sourceType":"notebook","isGpuEnabled":false}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"import os\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\ntrain_images_dir = \"/kaggle/input/byu-locating-bacterial-flagellar-motors-v2/train\"\n\ntrain_csv_path = \"/kaggle/input/byu-locating-bacterial-flagellar-motors-v2/train.csv\"\n\n\n# number of images to display\nnum_images = 10\n\n\ntrain_data = pd.read_csv(train_csv_path)\n\n\nfor i in range(num_images):\n    # Get the image name and corresponding data from the train.csv file\n    image_name = train_data.iloc[i][\"image_name\"]\n    x = train_data.iloc[i][\"x\"]\n    y = train_data.iloc[i][\"y\"]\n    motor_visible = train_data.iloc[i][\"motor_visible\"]\n\n    image_path = os.path.join(train_images_dir, image_name)\n    if os.path.isfile(image_path):\n        # we load the image \n        img = plt.imread(image_path)\n\n        # Create a plot & display image\n        fig, ax = plt.subplots(figsize=(10, 10))\n        ax.imshow(img, cmap='gray')\n\n        # Check if the motor is visible and both x and y are not -1\n        if motor_visible == 1 and x != -1 and y != -1:\n            # Plot the (x, y) coordinate as a dot\n            ax.plot(x, y, 'ro', markersize=10)\n\n            # Add motor label\n            text = ax.annotate('motor', (x, y), xytext=(10, 10), textcoords='offset points', fontsize=16, fontweight='bold', bbox=dict(boxstyle='square,pad=0.3', fc='white', ec='none', alpha=0.5))\n            text.set_visible(True)\n       \n        ax.set_xticks([])\n        ax.set_yticks([])\n\n        plt.show()\n    else:\n        print(f\"Image {image_name} not found in the train images folder.\")","metadata":{"execution":{"iopub.status.busy":"2024-04-04T23:09:55.999651Z","iopub.execute_input":"2024-04-04T23:09:56.000215Z","iopub.status.idle":"2024-04-04T23:10:03.013711Z","shell.execute_reply.started":"2024-04-04T23:09:56.000156Z","shell.execute_reply":"2024-04-04T23:10:03.011825Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"train_images_dir = \"/kaggle/input/byu-locating-bacterial-flagellar-motors-v2/train\"\ntrain_csv_path = \"/kaggle/input/byu-locating-bacterial-flagellar-motors-v2/train.csv\"\n\n# Set the number of images to process\nnum_images = 10\n\ntrain_data = pd.read_csv(train_csv_path)\n\nfig, axs = plt.subplots(nrows=2, ncols=5, figsize=(20, 8))\n\n\nfor i in range(num_images):\n    image_name = train_data.iloc[i][\"image_name\"]\n    x = train_data.iloc[i][\"x\"]\n    y = train_data.iloc[i][\"y\"]\n    motor_visible = train_data.iloc[i][\"motor_visible\"]\n\n    image_path = os.path.join(train_images_dir, image_name)\n    if os.path.isfile(image_path):\n\n        img = plt.imread(image_path)\n\n        row = i // 5\n        col = i % 5\n\n        axs[row, col].imshow(img, cmap='gray')\n\n        # Check if the motor is visible and both x and y are not -1\n        if motor_visible == 1 and x != -1 and y != -1:\n\n            axs[row, col].plot(x, y, 'ro', markersize=10)\n\n            text = axs[row, col].annotate('motor', (x, y), xytext=(10, 10), textcoords='offset points', fontsize=16, fontweight='bold', bbox=dict(boxstyle='square,pad=0.3', fc='white', ec='none', alpha=0.5))\n            text.set_visible(True)\n\n#         axs[row, col].set_xticks([])\n#         axs[row, col].set_yticks([])\n    else:\n        print(f\"Image {image_name} not found in the train images folder.\")\n\nplt.subplots_adjust(wspace=0.3, hspace=0.3)\n\nplt.show()","metadata":{"execution":{"iopub.status.busy":"2024-04-04T23:12:10.432470Z","iopub.execute_input":"2024-04-04T23:12:10.433089Z","iopub.status.idle":"2024-04-04T23:12:12.728012Z","shell.execute_reply.started":"2024-04-04T23:12:10.433037Z","shell.execute_reply":"2024-04-04T23:12:12.726556Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}