{
  "id": 180459,
  "title": "scoring error",
  "url": "/competitions/osic-pulmonary-fibrosis-progression/discussion/180459",
  "author_name": "",
  "post_date": "2020-09-05T06:20:39.560865100Z",
  "votes": 4,
  "comment_count": 13,
  "views": 0,
  "content": "<p>When I only used Tabular data to submit, there is no error at all, however, when I added the features from CT images, I got the submission scoring error. I used the same code to generate the submission.csv when I only worked with the tabular data, so there should be no format issue.</p>\n<p>The code read the images is as follow:</p>\n<pre><code>root_dir = Path(\"/kaggle/input/osic-pulmonary-fibrosis-progression\")\n\nsub = pd.read_csv(Path(root_dir)/\"sample_submission.csv\")\nsub['Patient'] = sub['Patient_Week'].apply(lambda x: x.split('_')[0])\nPatient_ids = set(sub.Patient)\ntest = pd.read_csv(Path(root_dir)/\"test.csv\")\nPatient_ids == set(test.Patient) # this is true\n\ndicom_root_path = '/kaggle/input/osic-pulmonary-fibrosis-progression/test/'\nPatients_id = os.listdir(dicom_root_path)\nfor Patient_id in Patients_id:\n    dicom_id_path = glob.glob(dicom_root_path + Patient_id + \"/*\")\n    for patient_dicom_id_path in dicom_id_path:\n         dicom = pydicom.dcmread(patient_dicom_id_path)\n         ... ...\n</code></pre>\n<p>I think the code is adapted to the hidden dataset. The imaging process also worked fine either locally or on Kaggle notebook but always get the scoring error. Has anyone even encountered such an issue? Any idea what might be wrong? Thanks!</p>",
  "messages": [
    {
      "id": "998850",
      "postDate": "09/05/2020 06:20:39",
      "content": "<p>When I only used Tabular data to submit, there is no error at all, however, when I added the features from CT images, I got the submission scoring error. I used the same code to generate the submission.csv when I only worked with the tabular data, so there should be no format issue.</p>\n<p>The code read the images is as follow:</p>\n<pre><code>root_dir = Path(\"/kaggle/input/osic-pulmonary-fibrosis-progression\")\n\nsub = pd.read_csv(Path(root_dir)/\"sample_submission.csv\")\nsub['Patient'] = sub['Patient_Week'].apply(lambda x: x.split('_')[0])\nPatient_ids = set(sub.Patient)\ntest = pd.read_csv(Path(root_dir)/\"test.csv\")\nPatient_ids == set(test.Patient) # this is true\n\ndicom_root_path = '/kaggle/input/osic-pulmonary-fibrosis-progression/test/'\nPatients_id = os.listdir(dicom_root_path)\nfor Patient_id in Patients_id:\n    dicom_id_path = glob.glob(dicom_root_path + Patient_id + \"/*\")\n    for patient_dicom_id_path in dicom_id_path:\n         dicom = pydicom.dcmread(patient_dicom_id_path)\n         ... ...\n</code></pre>\n<p>I think the code is adapted to the hidden dataset. The imaging process also worked fine either locally or on Kaggle notebook but always get the scoring error. Has anyone even encountered such an issue? Any idea what might be wrong? Thanks!</p>",
      "rawMarkdown": "When I only used Tabular data to submit, there is no error at all, however, when I added the features from CT images, I got the submission scoring error. I used the same code to generate the submission.csv when I only worked with the tabular data, so there should be no format issue.\n\nThe code read the images is as follow:\n\n```\nroot_dir = Path(\"/kaggle/input/osic-pulmonary-fibrosis-progression\")\n\nsub = pd.read_csv(Path(root_dir)/\"sample_submission.csv\")\nsub['Patient'] = sub['Patient_Week'].apply(lambda x: x.split('_')[0])\nPatient_ids = set(sub.Patient)\ntest = pd.read_csv(Path(root_dir)/\"test.csv\")\nPatient_ids == set(test.Patient) # this is true\n\ndicom_root_path = '/kaggle/input/osic-pulmonary-fibrosis-progression/test/'\nPatients_id = os.listdir(dicom_root_path)\nfor Patient_id in Patients_id:\n    dicom_id_path = glob.glob(dicom_root_path + Patient_id + \"/*\")\n    for patient_dicom_id_path in dicom_id_path:\n         dicom = pydicom.dcmread(patient_dicom_id_path)\n         ... ...\n```\nI think the code is adapted to the hidden dataset. The imaging process also worked fine either locally or on Kaggle notebook but always get the scoring error. Has anyone even encountered such an issue? Any idea what might be wrong? Thanks!",
      "votes": null
    },
    {
      "id": "998922",
      "postDate": "09/05/2020 07:43:17",
      "content": "<p>I have the same problem, and think there is some problem/missing info for some of the patients (running it on only the first patient works fine). Not sure where the issue is exactly (maybe some corrupted file or missing metadata?).</p>",
      "rawMarkdown": "I have the same problem, and think there is some problem/missing info for some of the patients (running it on only the first patient works fine). Not sure where the issue is exactly (maybe some corrupted file or missing metadata?).",
      "votes": null
    },
    {
      "id": "999205",
      "postDate": "09/05/2020 13:20:43",
      "content": "<p>Try to debug by sumiting, if ther is missing data submit sample_submission as it is else submit ur prediiction.</p>\n<p>it cost submission trys but worth it.</p>",
      "rawMarkdown": "Try to debug by sumiting, if ther is missing data submit sample_submission as it is else submit ur prediiction.\n\nit cost submission trys but worth it.",
      "votes": null
    },
    {
      "id": "999465",
      "postDate": "09/05/2020 16:59:47",
      "content": "<p>So you think the final output might miss some data compared to the sample_submission? How this would happen and how to know which data are missing? Thanks!</p>",
      "rawMarkdown": "So you think the final output might miss some data compared to the sample_submission? How this would happen and how to know which data are missing? Thanks!",
      "votes": null
    },
    {
      "id": "999469",
      "postDate": "09/05/2020 17:02:56",
      "content": "<p>What do you mean by \"running it on the first patient works fine\"? I am not sure about the corrupted file but the organizer says all images in the hidden set are readable. Are you saying that some patients in hidden set do not contain any images?</p>",
      "rawMarkdown": "What do you mean by \"running it on the first patient works fine\"? I am not sure about the corrupted file but the organizer says all images in the hidden set are readable. Are you saying that some patients in hidden set do not contain any images?",
      "votes": null
    },
    {
      "id": "999479",
      "postDate": "09/05/2020 17:11:27",
      "content": "<p>okay, I might know where the error is. There some missing slice and processing all the image need <code>sort()</code>, however, the hidden dateset have images end with dcm or dicom, so we might need delicated regular expression to retrieve the number in <code>1.dcm</code> or <code>1.dicom</code>. The public data has file name of <code>dcm</code> and people usually do <code>filename[:-4]</code> to get the image number. I will try to fix this later and let you know if this is the reason</p>",
      "rawMarkdown": "okay, I might know where the error is. There some missing slice and processing all the image need ```sort()```, however, the hidden dateset have images end with dcm or dicom, so we might need delicated regular expression to retrieve the number in ```1.dcm``` or ```1.dicom```. The public data has file name of ```dcm``` and people usually do ```filename[:-4]``` to get the image number. I will try to fix this later and let you know if this is the reason",
      "votes": null
    },
    {
      "id": "999482",
      "postDate": "09/05/2020 17:13:08",
      "content": "<p>If I run my code and then submit just the sample submission, it fails. But if I run my code only reading the first (or a few) patients data it doesn't fail. So I think there's some problem with some of dicom files, but I'm not sure what it is.</p>",
      "rawMarkdown": "If I run my code and then submit just the sample submission, it fails. But if I run my code only reading the first (or a few) patients data it doesn't fail. So I think there's some problem with some of dicom files, but I'm not sure what it is.",
      "votes": null
    },
    {
      "id": "999484",
      "postDate": "09/05/2020 17:13:54",
      "content": "<p>Oh that's a great point, I rely on the files ending in .dcm. I will look into that thanks.</p>",
      "rawMarkdown": "Oh that's a great point, I rely on the files ending in .dcm. I will look into that thanks.",
      "votes": null
    },
    {
      "id": "999526",
      "postDate": "09/05/2020 18:03:49",
      "content": "<p>If you just submit the sample submission, it should pass the test. The Patient_week column should contain all the sample we wanted to predict, right? I do not know why the sample submission would fail, that is weird….</p>\n<p>check this thread: <a href=\"https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372\" target=\"_blank\">https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372</a>, the host said the images in hidden dataset are all readable with normal pydicom implementation</p>\n<p>Also check the comments in this notebook: <a href=\"https://www.kaggle.com/nooblearning/submission-4/comments\" target=\"_blank\">https://www.kaggle.com/nooblearning/submission-4/comments</a>, someone mentioned that there are different filename</p>",
      "rawMarkdown": "If you just submit the sample submission, it should pass the test. The Patient_week column should contain all the sample we wanted to predict, right? I do not know why the sample submission would fail, that is weird....\n\ncheck this thread: https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372, the host said the images in hidden dataset are all readable with normal pydicom implementation\n\nAlso check the comments in this notebook: https://www.kaggle.com/nooblearning/submission-4/comments, someone mentioned that there are different filename",
      "votes": null
    },
    {
      "id": "999845",
      "postDate": "09/06/2020 04:48:34",
      "content": "<p>I was running my code and then submitting the sample so the code before submitting was giving an error. I think its a combination of some patients having .dicom and <a href=\"https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/180442\" target=\"_blank\">this.</a><br>\nI fixed the sorting with files = sorted(files, key = lambda x: int(x.split('/')[-1].split('.')[0])) instead of filename[:-4]. </p>",
      "rawMarkdown": "I was running my code and then submitting the sample so the code before submitting was giving an error. I think its a combination of some patients having .dicom and [this.](https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/180442)\nI fixed the sorting with files = sorted(files, key = lambda x: int(x.split('/')[-1].split('.')[0])) instead of filename[:-4].",
      "votes": null
    },
    {
      "id": "999854",
      "postDate": "09/06/2020 05:06:48",
      "content": "<p>Thanks for the info. Actually I do not understand the reason to sort the DICOM images, I saw people sort slices, which make more sense.</p>\n<p>I speaking of the attributes, the following is the function to scan the image, which I borrowed from other notebook:</p>\n<pre><code>def load_scan(path):\n    \"\"\"\n    Loads scans from a folder and into a list.\n\n    Parameters: path (Folder path)\n\n    Returns: slices (List of slices)\n    \"\"\"\n    slices = [pydicom.read_file(path + '/' + s) for s in os.listdir(path)]\n    slices.sort(key = lambda x: int(x.InstanceNumber))\n\n    try:\n        slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])\n    except:\n        try:\n            slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)\n        except:\n            slice_thickness = slices[0].SliceThickness\n\n    for s in slices:\n        s.SliceThickness = slice_thickness\n\n    return slices\n</code></pre>\n<p>I think it avoid the unavailable SliceLocation</p>\n<p>Did you still get error after modifying your code?</p>",
      "rawMarkdown": "Thanks for the info. Actually I do not understand the reason to sort the DICOM images, I saw people sort slices, which make more sense.\n\nI speaking of the attributes, the following is the function to scan the image, which I borrowed from other notebook:\n```\ndef load_scan(path):\n    \"\"\"\n    Loads scans from a folder and into a list.\n    \n    Parameters: path (Folder path)\n    \n    Returns: slices (List of slices)\n    \"\"\"\n    slices = [pydicom.read_file(path + '/' + s) for s in os.listdir(path)]\n    slices.sort(key = lambda x: int(x.InstanceNumber))\n    \n    try:\n        slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])\n    except:\n        try:\n            slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)\n        except:\n            slice_thickness = slices[0].SliceThickness\n        \n    for s in slices:\n        s.SliceThickness = slice_thickness\n        \n    return slices\n```\nI think it avoid the unavailable SliceLocation\n\nDid you still get error after modifying your code?",
      "votes": null
    },
    {
      "id": "1000076",
      "postDate": "09/06/2020 09:04:35",
      "content": "<p>Yeah I'm still getting an error, I'm not sure why. <br>\nEdit: Turns out its because one of the patients has completely blank masks when the masking code is run on their CT scans. No idea how to debug for this because the masking code works for all the training set patients lol.</p>",
      "rawMarkdown": "Yeah I'm still getting an error, I'm not sure why. \nEdit: Turns out its because one of the patients has completely blank masks when the masking code is run on their CT scans. No idea how to debug for this because the masking code works for all the training set patients lol.",
      "votes": null
    },
    {
      "id": "1000174",
      "postDate": "09/06/2020 11:01:53",
      "content": "<p>At least you will know if their is missing data, if that is the case you hve to invistigate the possibilities which may be the cause</p>",
      "rawMarkdown": "At least you will know if their is missing data, if that is the case you hve to invistigate the possibilities which may be the cause",
      "votes": null
    },
    {
      "id": "1000368",
      "postDate": "09/06/2020 13:40:29",
      "content": "<p>Thanks for the info, I think if there is a blank image, then some image process functions would get some error, I will check it. Also, please let me know if you find anything, thanks!</p>",
      "rawMarkdown": "Thanks for the info, I think if there is a blank image, then some image process functions would get some error, I will check it. Also, please let me know if you find anything, thanks!",
      "votes": null
    }
  ],
  "comments": [
    {
      "id": 998922,
      "author_name": "humphreymunn",
      "author_url": "",
      "post_date": "09/05/2020 07:43:17",
      "content": "<p>I have the same problem, and think there is some problem/missing info for some of the patients (running it on only the first patient works fine). Not sure where the issue is exactly (maybe some corrupted file or missing metadata?).</p>",
      "votes": null,
      "replies": [
        {
          "id": 999469,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/05/2020 17:02:56",
          "content": "<p>What do you mean by \"running it on the first patient works fine\"? I am not sure about the corrupted file but the organizer says all images in the hidden set are readable. Are you saying that some patients in hidden set do not contain any images?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999479,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/05/2020 17:11:27",
          "content": "<p>okay, I might know where the error is. There some missing slice and processing all the image need <code>sort()</code>, however, the hidden dateset have images end with dcm or dicom, so we might need delicated regular expression to retrieve the number in <code>1.dcm</code> or <code>1.dicom</code>. The public data has file name of <code>dcm</code> and people usually do <code>filename[:-4]</code> to get the image number. I will try to fix this later and let you know if this is the reason</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999482,
          "author_name": "humphreymunn",
          "author_url": "",
          "post_date": "09/05/2020 17:13:08",
          "content": "<p>If I run my code and then submit just the sample submission, it fails. But if I run my code only reading the first (or a few) patients data it doesn't fail. So I think there's some problem with some of dicom files, but I'm not sure what it is.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999484,
          "author_name": "humphreymunn",
          "author_url": "",
          "post_date": "09/05/2020 17:13:54",
          "content": "<p>Oh that's a great point, I rely on the files ending in .dcm. I will look into that thanks.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999526,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/05/2020 18:03:49",
          "content": "<p>If you just submit the sample submission, it should pass the test. The Patient_week column should contain all the sample we wanted to predict, right? I do not know why the sample submission would fail, that is weird….</p>\n<p>check this thread: <a href=\"https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372\" target=\"_blank\">https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372</a>, the host said the images in hidden dataset are all readable with normal pydicom implementation</p>\n<p>Also check the comments in this notebook: <a href=\"https://www.kaggle.com/nooblearning/submission-4/comments\" target=\"_blank\">https://www.kaggle.com/nooblearning/submission-4/comments</a>, someone mentioned that there are different filename</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999845,
          "author_name": "humphreymunn",
          "author_url": "",
          "post_date": "09/06/2020 04:48:34",
          "content": "<p>I was running my code and then submitting the sample so the code before submitting was giving an error. I think its a combination of some patients having .dicom and <a href=\"https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/180442\" target=\"_blank\">this.</a><br>\nI fixed the sorting with files = sorted(files, key = lambda x: int(x.split('/')[-1].split('.')[0])) instead of filename[:-4]. </p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 999854,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/06/2020 05:06:48",
          "content": "<p>Thanks for the info. Actually I do not understand the reason to sort the DICOM images, I saw people sort slices, which make more sense.</p>\n<p>I speaking of the attributes, the following is the function to scan the image, which I borrowed from other notebook:</p>\n<pre><code>def load_scan(path):\n    \"\"\"\n    Loads scans from a folder and into a list.\n\n    Parameters: path (Folder path)\n\n    Returns: slices (List of slices)\n    \"\"\"\n    slices = [pydicom.read_file(path + '/' + s) for s in os.listdir(path)]\n    slices.sort(key = lambda x: int(x.InstanceNumber))\n\n    try:\n        slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])\n    except:\n        try:\n            slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)\n        except:\n            slice_thickness = slices[0].SliceThickness\n\n    for s in slices:\n        s.SliceThickness = slice_thickness\n\n    return slices\n</code></pre>\n<p>I think it avoid the unavailable SliceLocation</p>\n<p>Did you still get error after modifying your code?</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1000076,
          "author_name": "humphreymunn",
          "author_url": "",
          "post_date": "09/06/2020 09:04:35",
          "content": "<p>Yeah I'm still getting an error, I'm not sure why. <br>\nEdit: Turns out its because one of the patients has completely blank masks when the masking code is run on their CT scans. No idea how to debug for this because the masking code works for all the training set patients lol.</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1000368,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/06/2020 13:40:29",
          "content": "<p>Thanks for the info, I think if there is a blank image, then some image process functions would get some error, I will check it. Also, please let me know if you find anything, thanks!</p>",
          "votes": null,
          "replies": []
        }
      ]
    },
    {
      "id": 999205,
      "author_name": "servietsky",
      "author_url": "",
      "post_date": "09/05/2020 13:20:43",
      "content": "<p>Try to debug by sumiting, if ther is missing data submit sample_submission as it is else submit ur prediiction.</p>\n<p>it cost submission trys but worth it.</p>",
      "votes": null,
      "replies": [
        {
          "id": 999465,
          "author_name": "skyleov",
          "author_url": "",
          "post_date": "09/05/2020 16:59:47",
          "content": "<p>So you think the final output might miss some data compared to the sample_submission? How this would happen and how to know which data are missing? Thanks!</p>",
          "votes": null,
          "replies": []
        },
        {
          "id": 1000174,
          "author_name": "servietsky",
          "author_url": "",
          "post_date": "09/06/2020 11:01:53",
          "content": "<p>At least you will know if their is missing data, if that is the case you hve to invistigate the possibilities which may be the cause</p>",
          "votes": null,
          "replies": []
        }
      ]
    }
  ],
  "raw_markdown_by_id": {
    "998850": "When I only used Tabular data to submit, there is no error at all, however, when I added the features from CT images, I got the submission scoring error. I used the same code to generate the submission.csv when I only worked with the tabular data, so there should be no format issue.\n\nThe code read the images is as follow:\n\n```\nroot_dir = Path(\"/kaggle/input/osic-pulmonary-fibrosis-progression\")\n\nsub = pd.read_csv(Path(root_dir)/\"sample_submission.csv\")\nsub['Patient'] = sub['Patient_Week'].apply(lambda x: x.split('_')[0])\nPatient_ids = set(sub.Patient)\ntest = pd.read_csv(Path(root_dir)/\"test.csv\")\nPatient_ids == set(test.Patient) # this is true\n\ndicom_root_path = '/kaggle/input/osic-pulmonary-fibrosis-progression/test/'\nPatients_id = os.listdir(dicom_root_path)\nfor Patient_id in Patients_id:\n    dicom_id_path = glob.glob(dicom_root_path + Patient_id + \"/*\")\n    for patient_dicom_id_path in dicom_id_path:\n         dicom = pydicom.dcmread(patient_dicom_id_path)\n         ... ...\n```\nI think the code is adapted to the hidden dataset. The imaging process also worked fine either locally or on Kaggle notebook but always get the scoring error. Has anyone even encountered such an issue? Any idea what might be wrong? Thanks!",
    "998922": "I have the same problem, and think there is some problem/missing info for some of the patients (running it on only the first patient works fine). Not sure where the issue is exactly (maybe some corrupted file or missing metadata?).",
    "999205": "Try to debug by sumiting, if ther is missing data submit sample_submission as it is else submit ur prediiction.\n\nit cost submission trys but worth it.",
    "999465": "So you think the final output might miss some data compared to the sample_submission? How this would happen and how to know which data are missing? Thanks!",
    "999469": "What do you mean by \"running it on the first patient works fine\"? I am not sure about the corrupted file but the organizer says all images in the hidden set are readable. Are you saying that some patients in hidden set do not contain any images?",
    "999479": "okay, I might know where the error is. There some missing slice and processing all the image need ```sort()```, however, the hidden dateset have images end with dcm or dicom, so we might need delicated regular expression to retrieve the number in ```1.dcm``` or ```1.dicom```. The public data has file name of ```dcm``` and people usually do ```filename[:-4]``` to get the image number. I will try to fix this later and let you know if this is the reason",
    "999482": "If I run my code and then submit just the sample submission, it fails. But if I run my code only reading the first (or a few) patients data it doesn't fail. So I think there's some problem with some of dicom files, but I'm not sure what it is.",
    "999484": "Oh that's a great point, I rely on the files ending in .dcm. I will look into that thanks.",
    "999526": "If you just submit the sample submission, it should pass the test. The Patient_week column should contain all the sample we wanted to predict, right? I do not know why the sample submission would fail, that is weird....\n\ncheck this thread: https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/166957#931372, the host said the images in hidden dataset are all readable with normal pydicom implementation\n\nAlso check the comments in this notebook: https://www.kaggle.com/nooblearning/submission-4/comments, someone mentioned that there are different filename",
    "999845": "I was running my code and then submitting the sample so the code before submitting was giving an error. I think its a combination of some patients having .dicom and [this.](https://www.kaggle.com/c/osic-pulmonary-fibrosis-progression/discussion/180442)\nI fixed the sorting with files = sorted(files, key = lambda x: int(x.split('/')[-1].split('.')[0])) instead of filename[:-4].",
    "999854": "Thanks for the info. Actually I do not understand the reason to sort the DICOM images, I saw people sort slices, which make more sense.\n\nI speaking of the attributes, the following is the function to scan the image, which I borrowed from other notebook:\n```\ndef load_scan(path):\n    \"\"\"\n    Loads scans from a folder and into a list.\n    \n    Parameters: path (Folder path)\n    \n    Returns: slices (List of slices)\n    \"\"\"\n    slices = [pydicom.read_file(path + '/' + s) for s in os.listdir(path)]\n    slices.sort(key = lambda x: int(x.InstanceNumber))\n    \n    try:\n        slice_thickness = np.abs(slices[0].ImagePositionPatient[2] - slices[1].ImagePositionPatient[2])\n    except:\n        try:\n            slice_thickness = np.abs(slices[0].SliceLocation - slices[1].SliceLocation)\n        except:\n            slice_thickness = slices[0].SliceThickness\n        \n    for s in slices:\n        s.SliceThickness = slice_thickness\n        \n    return slices\n```\nI think it avoid the unavailable SliceLocation\n\nDid you still get error after modifying your code?",
    "1000076": "Yeah I'm still getting an error, I'm not sure why. \nEdit: Turns out its because one of the patients has completely blank masks when the masking code is run on their CT scans. No idea how to debug for this because the masking code works for all the training set patients lol.",
    "1000174": "At least you will know if their is missing data, if that is the case you hve to invistigate the possibilities which may be the cause",
    "1000368": "Thanks for the info, I think if there is a blank image, then some image process functions would get some error, I will check it. Also, please let me know if you find anything, thanks!"
  },
  "source": "meta"
}