{
  "id": 447605,
  "title": "Is image magnification a factor to be concerned about?",
  "url": "/competitions/UBC-OCEAN/discussion/447605",
  "author_name": "阳光开朗大男孩",
  "post_date": "2023-10-16T14:36:24.574000",
  "votes": 8,
  "comment_count": 11,
  "views": 0,
  "content": "<p>Based on the dataset description, It seems that the TMA images have a different magnification than the other images (40x v.s. 20x). What does this mean? Should we do any preprocessing for this?</p>",
  "messages": [
    {
      "id": 2484515,
      "postDate": "2023-10-16T14:36:24.573Z",
      "content": "<p>Based on the dataset description, It seems that the TMA images have a different magnification than the other images (40x v.s. 20x). What does this mean? Should we do any preprocessing for this?</p>",
      "rawMarkdown": "Based on the dataset description, It seems that the TMA images have a different magnification than the other images (40x v.s. 20x). What does this mean? Should we do any preprocessing for this?",
      "votes": 8
    },
    {
      "id": 2485087,
      "postDate": "2023-10-17T00:01:34.287Z",
      "content": "<p>I think so, but I'm not exactly sure. As the model splits the images into tiles, some of tools I've tried factor in the tile size in pixels, and the tile size in microns or the given magnification.</p>",
      "rawMarkdown": "I think so, but I'm not exactly sure. As the model splits the images into tiles, some of tools I've tried factor in the tile size in pixels, and the tile size in microns or the given magnification.",
      "replies": [
        {
          "id": 2485541,
          "postDate": "2023-10-17T09:07:50.843Z",
          "content": "<p>Many thanks! You really help me a lot, btw, I see that one of your notebooks provides code to convert png to tif, I'm wondering if it's possible to use openslide to regain the image at a different magnification after converting to tif, is this feasible?😂</p>",
          "rawMarkdown": "Many thanks! You really help me a lot, btw, I see that one of your notebooks provides code to convert png to tif, I'm wondering if it's possible to use openslide to regain the image at a different magnification after converting to tif, is this feasible?😂",
          "votes": 1,
          "replies": [
            {
              "id": 2485581,
              "postDate": "2023-10-17T09:33:34.420Z",
              "content": "<p>So far, I'm not really sure. <br>\nWhen I use pyvips and pprint to show the fields of both the original png, and the converted tif files, it's blank.<br>\n  <code>['width',\n 'height',\n 'bands',\n 'format',\n 'coding',\n 'interpretation',\n 'xoffset',\n 'yoffset',\n 'xres',\n 'yres',\n 'filename',\n 'vips-loader']</code><br>\nI think this is the cause of the errors I'm running into: </p>\n<ul>\n<li>Error loading slide Could not find magnification level matching 20x (closest: 10.0)</li>\n<li>Error loading slide missing MPP (openslide.mpp-x).</li>\n</ul>",
              "rawMarkdown": "So far, I'm not really sure. \nWhen I use pyvips and pprint to show the fields of both the original png, and the converted tif files, it's blank.\n  `['width',\n 'height',\n 'bands',\n 'format',\n 'coding',\n 'interpretation',\n 'xoffset',\n 'yoffset',\n 'xres',\n 'yres',\n 'filename',\n 'vips-loader']`\nI think this is the cause of the errors I'm running into: \n- Error loading slide Could not find magnification level matching 20x (closest: 10.0)\n- Error loading slide missing MPP (openslide.mpp-x).",
              "votes": 4
            },
            {
              "id": 2485721,
              "postDate": "2023-10-17T12:06:15.193Z",
              "content": "<p>I just found the large_image library and maybe it's helpful.<br>\nThis is the code I used for each png file:<br>\n<code>image.tiffsave(f\"{png_file[:-4]}.tif\", compression=\"jpeg\", Q=25, tile=True, pyramid=True)</code></p>\n<p>Using large_image reveals the resulting metadata:<br>\n<code>{'levels': 10, 'sizeX': 53143, 'sizeY': 39150, 'tileWidth': 128, 'tileHeight': 128, 'magnification': 0.028340000157438316, 'mm_x': 0.3528581490630419, 'mm_y': 0.3528581490630419, 'dtype': 'uint8', 'bandCount': 3}</code></p>\n<p>Using this file <a href=\"url\" target=\"_blank\">https://www.zmbh.uni-heidelberg.de/Central_Services/Imaging_Facility/info/Pixel.pdf</a> as a guide, 40x magnification is 0.161 microns per pixel, and 20x is 0.323 microns per pixel.</p>\n<p>image.tiffsave can take arguments for tile_width (int) – Tile width in pixels and tile_height (int) – Tile height in pixels, so it might be a matter of adjusting the values.</p>",
              "rawMarkdown": "I just found the large_image library and maybe it's helpful.\nThis is the code I used for each png file:\n`image.tiffsave(f\"{png_file[:-4]}.tif\", compression=\"jpeg\", Q=25, tile=True, pyramid=True)`\n\nUsing large_image reveals the resulting metadata:\n`{'levels': 10, 'sizeX': 53143, 'sizeY': 39150, 'tileWidth': 128, 'tileHeight': 128, 'magnification': 0.028340000157438316, 'mm_x': 0.3528581490630419, 'mm_y': 0.3528581490630419, 'dtype': 'uint8', 'bandCount': 3}`\n\nUsing this file [https://www.zmbh.uni-heidelberg.de/Central_Services/Imaging_Facility/info/Pixel.pdf](url) as a guide, 40x magnification is 0.161 microns per pixel, and 20x is 0.323 microns per pixel.\n\nimage.tiffsave can take arguments for tile_width (int) – Tile width in pixels and tile_height (int) – Tile height in pixels, so it might be a matter of adjusting the values.",
              "votes": 7
            },
            {
              "id": 2485732,
              "postDate": "2023-10-17T12:19:45.133Z",
              "content": "<p>Nice work! I'll try it later. Thanks again!</p>",
              "rawMarkdown": "Nice work! I'll try it later. Thanks again!",
              "votes": 1
            },
            {
              "id": 2487800,
              "postDate": "2023-10-18T19:03:35.840Z",
              "content": "<p>Dear Noli, do you have a tip to get pyvips running offline in a kaggle kernel? - I have difficulties getting it running both online and offline, already looked for solutions on kaggle and online but often get the error OSError: cannot load library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42' </p>\n<ul>\n<li>Best, Alex</li>\n</ul>",
              "rawMarkdown": "Dear Noli, do you have a tip to get pyvips running offline in a kaggle kernel? - I have difficulties getting it running both online and offline, already looked for solutions on kaggle and online but often get the error OSError: cannot load library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42' \n\n- Best, Alex"
            },
            {
              "id": 2488020,
              "postDate": "2023-10-19T00:39:25.530Z",
              "content": "<p>Just follow the instructions of the notebook called: <strong>libvips/pyvips Installation and Getting Started</strong></p>\n<p>Essentially, you create your own version of that notebook, where it downloads all the libraries and saves it as an output. <br>\nThen create a notebook for the submission, and on the right side menu, press \"+ Add Data\" then press \"Your Notebooks\" and select your notebook with the libraries that you saved as output.</p>\n<p>I tried it and it works without the libvips.so.42 error.</p>",
              "rawMarkdown": "Just follow the instructions of the notebook called: **libvips/pyvips Installation and Getting Started**\n\nEssentially, you create your own version of that notebook, where it downloads all the libraries and saves it as an output. \nThen create a notebook for the submission, and on the right side menu, press \"+ Add Data\" then press \"Your Notebooks\" and select your notebook with the libraries that you saved as output.\n\nI tried it and it works without the libvips.so.42 error.",
              "votes": 2
            },
            {
              "id": 2488261,
              "postDate": "2023-10-19T06:42:21.190Z",
              "content": "<p>Thank you Noli for your detailed reply! - Actually after following your steps I first got the same error message but when switching to gpu in the importing notebook it worked! </p>",
              "rawMarkdown": "Thank you Noli for your detailed reply! - Actually after following your steps I first got the same error message but when switching to gpu in the importing notebook it worked! "
            },
            {
              "id": 2490986,
              "postDate": "2023-10-21T08:39:26.317Z",
              "content": "<p>Me too, I have been facing this same issue</p>",
              "rawMarkdown": "Me too, I have been facing this same issue"
            },
            {
              "id": 2490997,
              "postDate": "2023-10-21T08:51:31.777Z",
              "content": "<p>Does it require GPU to be on? or what?</p>",
              "rawMarkdown": "Does it require GPU to be on? or what?"
            },
            {
              "id": 2491254,
              "postDate": "2023-10-21T13:09:16.430Z",
              "content": "<p>ye exactly! - once put to gpu notebook, it worked for me.</p>",
              "rawMarkdown": "ye exactly! - once put to gpu notebook, it worked for me."
            }
          ]
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2485087,
      "author_name": "Noli Alonso",
      "author_url": "",
      "post_date": "2023-10-17T00:01:34.287000",
      "content": "<p>I think so, but I'm not exactly sure. As the model splits the images into tiles, some of tools I've tried factor in the tile size in pixels, and the tile size in microns or the given magnification.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 2485541,
          "author_name": "阳光开朗大男孩",
          "author_url": "",
          "post_date": "2023-10-17T09:07:50.843000",
          "content": "<p>Many thanks! You really help me a lot, btw, I see that one of your notebooks provides code to convert png to tif, I'm wondering if it's possible to use openslide to regain the image at a different magnification after converting to tif, is this feasible?😂</p>",
          "votes": 1,
          "replies": [
            {
              "id": 2485581,
              "author_name": "Noli Alonso",
              "author_url": "",
              "post_date": "2023-10-17T09:33:34.420000",
              "content": "<p>So far, I'm not really sure. <br>\nWhen I use pyvips and pprint to show the fields of both the original png, and the converted tif files, it's blank.<br>\n  <code>['width',\n 'height',\n 'bands',\n 'format',\n 'coding',\n 'interpretation',\n 'xoffset',\n 'yoffset',\n 'xres',\n 'yres',\n 'filename',\n 'vips-loader']</code><br>\nI think this is the cause of the errors I'm running into: </p>\n<ul>\n<li>Error loading slide Could not find magnification level matching 20x (closest: 10.0)</li>\n<li>Error loading slide missing MPP (openslide.mpp-x).</li>\n</ul>",
              "votes": 4,
              "replies": []
            },
            {
              "id": 2485721,
              "author_name": "Noli Alonso",
              "author_url": "",
              "post_date": "2023-10-17T12:06:15.193000",
              "content": "<p>I just found the large_image library and maybe it's helpful.<br>\nThis is the code I used for each png file:<br>\n<code>image.tiffsave(f\"{png_file[:-4]}.tif\", compression=\"jpeg\", Q=25, tile=True, pyramid=True)</code></p>\n<p>Using large_image reveals the resulting metadata:<br>\n<code>{'levels': 10, 'sizeX': 53143, 'sizeY': 39150, 'tileWidth': 128, 'tileHeight': 128, 'magnification': 0.028340000157438316, 'mm_x': 0.3528581490630419, 'mm_y': 0.3528581490630419, 'dtype': 'uint8', 'bandCount': 3}</code></p>\n<p>Using this file <a href=\"url\" target=\"_blank\">https://www.zmbh.uni-heidelberg.de/Central_Services/Imaging_Facility/info/Pixel.pdf</a> as a guide, 40x magnification is 0.161 microns per pixel, and 20x is 0.323 microns per pixel.</p>\n<p>image.tiffsave can take arguments for tile_width (int) – Tile width in pixels and tile_height (int) – Tile height in pixels, so it might be a matter of adjusting the values.</p>",
              "votes": 7,
              "replies": []
            },
            {
              "id": 2485732,
              "author_name": "阳光开朗大男孩",
              "author_url": "",
              "post_date": "2023-10-17T12:19:45.133000",
              "content": "<p>Nice work! I'll try it later. Thanks again!</p>",
              "votes": 1,
              "replies": []
            },
            {
              "id": 2487800,
              "author_name": "Alexandra",
              "author_url": "",
              "post_date": "2023-10-18T19:03:35.840000",
              "content": "<p>Dear Noli, do you have a tip to get pyvips running offline in a kaggle kernel? - I have difficulties getting it running both online and offline, already looked for solutions on kaggle and online but often get the error OSError: cannot load library 'libvips.so.42': libvips.so.42: cannot open shared object file: No such file or directory.  Additionally, ctypes.util.find_library() did not manage to locate a library called 'libvips.so.42' </p>\n<ul>\n<li>Best, Alex</li>\n</ul>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2488020,
              "author_name": "Noli Alonso",
              "author_url": "",
              "post_date": "2023-10-19T00:39:25.530000",
              "content": "<p>Just follow the instructions of the notebook called: <strong>libvips/pyvips Installation and Getting Started</strong></p>\n<p>Essentially, you create your own version of that notebook, where it downloads all the libraries and saves it as an output. <br>\nThen create a notebook for the submission, and on the right side menu, press \"+ Add Data\" then press \"Your Notebooks\" and select your notebook with the libraries that you saved as output.</p>\n<p>I tried it and it works without the libvips.so.42 error.</p>",
              "votes": 2,
              "replies": []
            },
            {
              "id": 2488261,
              "author_name": "Alexandra",
              "author_url": "",
              "post_date": "2023-10-19T06:42:21.190000",
              "content": "<p>Thank you Noli for your detailed reply! - Actually after following your steps I first got the same error message but when switching to gpu in the importing notebook it worked! </p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2490986,
              "author_name": "samu2505",
              "author_url": "",
              "post_date": "2023-10-21T08:39:26.317000",
              "content": "<p>Me too, I have been facing this same issue</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2490997,
              "author_name": "samu2505",
              "author_url": "",
              "post_date": "2023-10-21T08:51:31.777000",
              "content": "<p>Does it require GPU to be on? or what?</p>",
              "votes": 0,
              "replies": []
            },
            {
              "id": 2491254,
              "author_name": "Alexandra",
              "author_url": "",
              "post_date": "2023-10-21T13:09:16.430000",
              "content": "<p>ye exactly! - once put to gpu notebook, it worked for me.</p>",
              "votes": 0,
              "replies": []
            }
          ]
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2484515": "Based on the dataset description, It seems that the TMA images have a different magnification than the other images (40x v.s. 20x). What does this mean? Should we do any preprocessing for this?",
    "2485087": "I think so, but I'm not exactly sure. As the model splits the images into tiles, some of tools I've tried factor in the tile size in pixels, and the tile size in microns or the given magnification."
  }
}