{
  "id": 434041,
  "title": "TotalSegmentator",
  "url": "/competitions/rsna-2023-abdominal-trauma-detection/discussion/434041",
  "author_name": "JanGlinko2",
  "post_date": "2023-08-23T19:26:45.418000",
  "votes": 7,
  "comment_count": 8,
  "views": 0,
  "content": "<p>Hey,</p>\n<p>has someone managed to run TotalSegmentor in Kaggle Notebook?<br>\nI'm getting some version mismatch errors. I've been trying to manually downgrade some packages, but I haven't succeeded in running inference.<br>\nI've been trying both original and latest environments.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Faae75d67a4f98fc08cede53261b50a98%2FScreenshot%20from%202023-08-23%2021-25-17.png?generation=1692818740485148&amp;alt=media\" alt=\"\"></p>",
  "messages": [
    {
      "id": 2405261,
      "postDate": "2023-08-23T19:26:45.420Z",
      "content": "<p>Hey,</p>\n<p>has someone managed to run TotalSegmentor in Kaggle Notebook?<br>\nI'm getting some version mismatch errors. I've been trying to manually downgrade some packages, but I haven't succeeded in running inference.<br>\nI've been trying both original and latest environments.<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Faae75d67a4f98fc08cede53261b50a98%2FScreenshot%20from%202023-08-23%2021-25-17.png?generation=1692818740485148&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "Hey,\n\nhas someone managed to run TotalSegmentor in Kaggle Notebook?\nI'm getting some version mismatch errors. I've been trying to manually downgrade some packages, but I haven't succeeded in running inference.\nI've been trying both original and latest environments.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Faae75d67a4f98fc08cede53261b50a98%2FScreenshot%20from%202023-08-23%2021-25-17.png?generation=1692818740485148&alt=media)",
      "votes": 7
    },
    {
      "id": 2407135,
      "postDate": "2023-08-24T21:00:38.250Z",
      "content": "<p><a href=\"https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline\" target=\"_blank\">https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline</a><br>\nThe dataset is in public mode too, enjoy!</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14573416%2Fe2a6c0f2b3adbe00bd408a33927debd6%2FScreenshot%20from%202023-08-24%2023-09-53.png?generation=1692911513058170&amp;alt=media\" alt=\"\"></p>",
      "rawMarkdown": "https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline\nThe dataset is in public mode too, enjoy!\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14573416%2Fe2a6c0f2b3adbe00bd408a33927debd6%2FScreenshot%20from%202023-08-24%2023-09-53.png?generation=1692911513058170&alt=media)",
      "votes": 3,
      "replies": [
        {
          "id": 2407523,
          "postDate": "2023-08-25T05:52:30.053Z",
          "content": "<p>Thank you!</p>",
          "rawMarkdown": "Thank you!"
        },
        {
          "id": 2408039,
          "postDate": "2023-08-25T11:58:25.127Z",
          "content": "<p>in additional, i recommend ITK-snap to veiw the results</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2Fdb70848442c8be03ab97149eaf400084%2FSelection_999(2967).png?generation=1692964579145552&amp;alt=media\" alt=\"\"></p>\n<p>there are many others tool available, but this is the easiest to use.<br>\njust drag the dicom folder/image into the application, followed by dragging the nii segmentation file.</p>",
          "rawMarkdown": "in additional, i recommend ITK-snap to veiw the results\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2Fdb70848442c8be03ab97149eaf400084%2FSelection_999(2967).png?generation=1692964579145552&alt=media)\n\nthere are many others tool available, but this is the easiest to use.\njust drag the dicom folder/image into the application, followed by dragging the nii segmentation file.",
          "votes": 3,
          "replies": [
            {
              "id": 2410431,
              "postDate": "2023-08-26T23:49:58.990Z",
              "content": "<p>if you have problem in aligning total segmentator results to original dicom images try this:</p>\n<pre><code>DCM2NIIX=\\\n    \n ():\n    \n    nii_dir = .join(nii_file.split()[:-])\n     nii_dir==:\n        nii_dir=\n    verbose_str =   verbose  \n    subprocess.call(, shell=)\n\n\nos.makedirs(, exist_ok=)\ndcm_to_nifti(\n    ,\n    ,\n    \n)\n</code></pre>\n<p>total segmentator  use the same function to convert dicom to nii. Hence Both <br>\ntotal segmentator results and your nii will aligned.</p>\n<p>further, you can read the nii header and compare with the dicom header to figure out how to change the axes for alignment</p>",
              "rawMarkdown": "if you have problem in aligning total segmentator results to original dicom images try this:\n\n```\n\nDCM2NIIX=\\\n\t'..../totalSegmentatorKaggle/nnunet/results/nnUNet/dcm2niix'\ndef dcm_to_nifti(dcm_dir, nii_file, verbose=True):\n\t#print(os.getcwd())\n\tnii_dir = '/'.join(nii_file.split('/')[:-1])\n\tif nii_dir=='':\n\t\tnii_dir='./'\n\tverbose_str = '' if verbose else '> /dev/null'\n\tsubprocess.call(f'{DCM2NIIX} -o {nii_dir} -z y -f {nii_file[len(nii_dir)+1:-7]} {dcm_dir} {verbose_str}', shell=True)\n\n#for example:\nos.makedirs(f'{out_dir}/train_images/{patient_id}', exist_ok=True)\ndcm_to_nifti(\n\tf'{data_dir}/train_images/{patient_id}/{series_id}',\n\tf'{out_dir}/train_images/{patient_id}/{series_id}.nii.gz',#nii_file\n\tFalse\n)\n\n```\n\ntotal segmentator  use the same function to convert dicom to nii. Hence Both \ntotal segmentator results and your nii will aligned.\n\nfurther, you can read the nii header and compare with the dicom header to figure out how to change the axes for alignment",
              "votes": 1
            }
          ]
        }
      ]
    },
    {
      "id": 2406277,
      "postDate": "2023-08-24T10:25:07.573Z",
      "content": "<p>Tried API, but stuck forever on:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Fe32228bb9522cfc93060daa9299b1ed0%2FScreenshot%20from%202023-08-24%2012-24-49.png?generation=1692872704198564&amp;alt=media\" alt=\"\"></p>\n<p>both CPU and GPU usage is 0% all the time.</p>",
      "rawMarkdown": "Tried API, but stuck forever on:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Fe32228bb9522cfc93060daa9299b1ed0%2FScreenshot%20from%202023-08-24%2012-24-49.png?generation=1692872704198564&alt=media)\n\nboth CPU and GPU usage is 0% all the time.",
      "votes": 1,
      "replies": [
        {
          "id": 2435839,
          "postDate": "2023-09-13T07:49:40.447Z",
          "content": "<p>This is probably a multiprocessing issue inside jupyter notebooks. locally I've faced the same problem with python ip.<br>\ntotalsegmentator() - loop restarting forever due to a multiprocessing code it has inside. <br>\nLocally it works fine with:<br>\nif <strong>name</strong> == '<strong>main</strong>':<br>\n    totalsegmentator()</p>",
          "rawMarkdown": "This is probably a multiprocessing issue inside jupyter notebooks. locally I've faced the same problem with python ip.\ntotalsegmentator() - loop restarting forever due to a multiprocessing code it has inside. \nLocally it works fine with:\nif __name__ == '__main__':\n    totalsegmentator()",
          "votes": 1
        }
      ]
    },
    {
      "id": 2405290,
      "postDate": "2023-08-23T19:52:03.237Z",
      "content": "<p>You might have better luck starting your notebook with an older image.</p>",
      "rawMarkdown": "You might have better luck starting your notebook with an older image.",
      "replies": [
        {
          "id": 2405334,
          "postDate": "2023-08-23T20:25:13.563Z",
          "content": "<p>There are only two, the latest and the original (older). I've tried both :/</p>",
          "rawMarkdown": "There are only two, the latest and the original (older). I've tried both :/",
          "votes": 1
        }
      ]
    }
  ],
  "comments": [
    {
      "id": 2407135,
      "author_name": "Antonio Félix",
      "author_url": "",
      "post_date": "2023-08-24T21:00:38.250000",
      "content": "<p><a href=\"https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline\" target=\"_blank\">https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline</a><br>\nThe dataset is in public mode too, enjoy!</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14573416%2Fe2a6c0f2b3adbe00bd408a33927debd6%2FScreenshot%20from%202023-08-24%2023-09-53.png?generation=1692911513058170&amp;alt=media\" alt=\"\"></p>",
      "votes": 3,
      "replies": [
        {
          "id": 2407523,
          "author_name": "JanGlinko2",
          "author_url": "",
          "post_date": "2023-08-25T05:52:30.053000",
          "content": "<p>Thank you!</p>",
          "votes": 0,
          "replies": []
        },
        {
          "id": 2408039,
          "author_name": "hengck23",
          "author_url": "",
          "post_date": "2023-08-25T11:58:25.127000",
          "content": "<p>in additional, i recommend ITK-snap to veiw the results</p>\n<p><img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F113660%2Fdb70848442c8be03ab97149eaf400084%2FSelection_999(2967).png?generation=1692964579145552&amp;alt=media\" alt=\"\"></p>\n<p>there are many others tool available, but this is the easiest to use.<br>\njust drag the dicom folder/image into the application, followed by dragging the nii segmentation file.</p>",
          "votes": 3,
          "replies": [
            {
              "id": 2410431,
              "author_name": "hengck23",
              "author_url": "",
              "post_date": "2023-08-26T23:49:58.990000",
              "content": "<p>if you have problem in aligning total segmentator results to original dicom images try this:</p>\n<pre><code>DCM2NIIX=\\\n    \n ():\n    \n    nii_dir = .join(nii_file.split()[:-])\n     nii_dir==:\n        nii_dir=\n    verbose_str =   verbose  \n    subprocess.call(, shell=)\n\n\nos.makedirs(, exist_ok=)\ndcm_to_nifti(\n    ,\n    ,\n    \n)\n</code></pre>\n<p>total segmentator  use the same function to convert dicom to nii. Hence Both <br>\ntotal segmentator results and your nii will aligned.</p>\n<p>further, you can read the nii header and compare with the dicom header to figure out how to change the axes for alignment</p>",
              "votes": 1,
              "replies": []
            }
          ]
        }
      ]
    },
    {
      "id": 2406277,
      "author_name": "JanGlinko2",
      "author_url": "",
      "post_date": "2023-08-24T10:25:07.573000",
      "content": "<p>Tried API, but stuck forever on:<br>\n<img src=\"https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Fe32228bb9522cfc93060daa9299b1ed0%2FScreenshot%20from%202023-08-24%2012-24-49.png?generation=1692872704198564&amp;alt=media\" alt=\"\"></p>\n<p>both CPU and GPU usage is 0% all the time.</p>",
      "votes": 1,
      "replies": [
        {
          "id": 2435839,
          "author_name": "Aleksandr Lavrikov",
          "author_url": "",
          "post_date": "2023-09-13T07:49:40.447000",
          "content": "<p>This is probably a multiprocessing issue inside jupyter notebooks. locally I've faced the same problem with python ip.<br>\ntotalsegmentator() - loop restarting forever due to a multiprocessing code it has inside. <br>\nLocally it works fine with:<br>\nif <strong>name</strong> == '<strong>main</strong>':<br>\n    totalsegmentator()</p>",
          "votes": 1,
          "replies": []
        }
      ]
    },
    {
      "id": 2405290,
      "author_name": "Sohier Dane",
      "author_url": "",
      "post_date": "2023-08-23T19:52:03.237000",
      "content": "<p>You might have better luck starting your notebook with an older image.</p>",
      "votes": 0,
      "replies": [
        {
          "id": 2405334,
          "author_name": "JanGlinko2",
          "author_url": "",
          "post_date": "2023-08-23T20:25:13.563000",
          "content": "<p>There are only two, the latest and the original (older). I've tried both :/</p>",
          "votes": 1,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "2405261": "Hey,\n\nhas someone managed to run TotalSegmentor in Kaggle Notebook?\nI'm getting some version mismatch errors. I've been trying to manually downgrade some packages, but I haven't succeeded in running inference.\nI've been trying both original and latest environments.\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Faae75d67a4f98fc08cede53261b50a98%2FScreenshot%20from%202023-08-23%2021-25-17.png?generation=1692818740485148&alt=media)",
    "2407135": "https://www.kaggle.com/code/enriquezaf/totalsegmentator-offline\nThe dataset is in public mode too, enjoy!\n\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F14573416%2Fe2a6c0f2b3adbe00bd408a33927debd6%2FScreenshot%20from%202023-08-24%2023-09-53.png?generation=1692911513058170&alt=media)",
    "2406277": "Tried API, but stuck forever on:\n![](https://www.googleapis.com/download/storage/v1/b/kaggle-forum-message-attachments/o/inbox%2F5506850%2Fe32228bb9522cfc93060daa9299b1ed0%2FScreenshot%20from%202023-08-24%2012-24-49.png?generation=1692872704198564&alt=media)\n\nboth CPU and GPU usage is 0% all the time.",
    "2405290": "You might have better luck starting your notebook with an older image."
  }
}