xmengli / H-DenseUNet

TMI 2018. H-DenseUNet: Hybrid Densely Connected UNet for Liver and Tumor Segmentation from CT Volumes
526 stars 161 forks source link

Could you please update the code you use about generating livermask? #39

Open shenhai1895 opened 5 years ago

shenhai1895 commented 5 years ago

hello, i wish to test your code on some new CT, but i do not find the code about generating the "livermask". could you update it in this repo?

xmengli commented 5 years ago

The liver mask is only used for speeding up the test procedure. In case you try on the new CT, I suggest you do not use liver mask.

shenhai1895 commented 5 years ago

thank you very much. in other words, the model only predict the segmentation in the area of the liver provided by livermask. is it right?

xmengli commented 5 years ago

Since the liver ct scans have very large number of slices, e.g., 512512800. So, test one image is very costly. The usage of liver mask can help narrow the test range to 512512300, for example. We can avoid test on useless slices.

mnc1423 commented 5 years ago

how do you test on new CT without loading liver mask?

shenhai1895 commented 5 years ago

Yes.

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: mnc1423 notifications@github.com 发送时间: Wednesday, July 10, 2019 4:19:21 PM 收件人: xmengli999/H-DenseUNet 抄送: shenhai1895; Author 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

how do you test on new CT without loading liver mask?

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24IAD4OI46TXMQTAVC3P6WLQTA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZSWIMY#issuecomment-509961267, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24N6HKODY7O5EJN5PEDP6WLQTANCNFSM4H6YVIFA.

mnc1423 commented 5 years ago

how? since test.py won't work. You wrote a new code?

xmengli commented 5 years ago

Just comment the "liver mask loading" part.

mnc1423 commented 5 years ago

Thanks for the help! :)

mnc1423 commented 5 years ago

commenting " mask, mask_header = load(args.liver_path + str(id) + '-ori.nii') " seems to result in UnboundLocalError: local variable 'mask' referenced before assignment should set mask to [2]?

mnc1423 commented 5 years ago

Cant seem to get it to work QQ. can i load a blank liver mask? commenting seems to yield in more errors any guild lines would help Thank you in advance

shenhai1895 commented 5 years ago

In fact, the liver mask is not nessasary. You should debug the code step by step and remove or modify the code about liver mask.

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: mnc1423 notifications@github.com 发送时间: Wednesday, July 24, 2019 2:38:17 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

Cant seem to get it to work QQ. can i load a blank liver mask? commenting seems to yield in more errors any guild lines would help Thank you in advance

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24MBH2X2F7EH574CMETQA72FTA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2VKUUY#issuecomment-514501203, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24PCSOIDIXW2BYA5M6DQA72FTANCNFSM4H6YVIFA.

mnc1423 commented 5 years ago

i changed the mini and maxi in the code to fit the size of the CT volumes so mini should be (0 0 0) maxi should be size of the CT shape -1 on Z (x,y,z) seems to run out of resources.. running on titan Xp QQ

shenhai1895 commented 5 years ago

In the file func.py, I do like this: [cid:image001.png@01D54560.BEC7F4D0]

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: mnc1423 notifications@github.com 发送时间: Saturday, July 27, 2019 2:09:40 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

i changed the mini and maxi in the code to fit the size of the CT volumes so mini should be (0 0 0) maxi should be size of the CT shape -1 on Z (x,y,z) seems to run out of resources.. running on titan Xp QQ

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24MYITM4IMHJF64WZKTQBPRCJA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD26ERXY#issuecomment-515655903, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24ITJFMY4RPAYB7E7I3QBPRCJANCNFSM4H6YVIFA.

mnc1423 commented 5 years ago

Can't See the .png file

shenhai1895 commented 5 years ago

x = imgs_test.shape[0] y = imgs_test.shape[1] z = imgs_test.shape[2]

right_cols = int(min(z, maxi[2] + 10) - img_cols)

left_cols = max(0, min(mini[2] - 5, right_cols))

right_cols = int(z - img_cols) left_cols = 0 score = np.zeros((x, y, z, num), dtype='float32') score_num = np.zeros((x, y, z, num), dtype='int16')

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: mnc1423 notifications@github.com 发送时间: Sunday, July 28, 2019 5:32:22 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

Can't See the .png file

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24J5KZA43ZB5HGNYYTDQBVRSNA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD263AJI#issuecomment-515747877, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24PQXZ2KTBKZCUDGZ3DQBVRSNANCNFSM4H6YVIFA.

mnc1423 commented 5 years ago

Thank you for the help! Can i ask what GPU you're using?

shenhai1895 commented 5 years ago

2080Ti*2. You can run the model on two gpus, and the OOM will be solved. 发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: mnc1423 notifications@github.com 发送时间: Sunday, July 28, 2019 5:36:39 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

Thank you for the help! Can i ask what GPU you're using?

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24I6DA2JCZAEZZWN2T3QBVSCPA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD263CPQ#issuecomment-515748158, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24OBILQGJCYVQZDYNBTQBVSCPANCNFSM4H6YVIFA.

mnc1423 commented 5 years ago

Thank you for the help!

guolihong commented 5 years ago

After commenting the part of loading mask,what do you change for preserving results in test.py?

shenhai1895 commented 4 years ago

You could use the liver_res predicted by the model as the mask. Like this

mask = liver_res

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: guolihong notifications@github.com 发送时间: Tuesday, July 30, 2019 7:50:43 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

After commenting the part of loading mask,what do you change for preserving results in test.py?

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24J5NT3SGEES4KMTRFLQCATJHA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3DWXWI#issuecomment-516385753, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24KZHIY5TVE5CMZB3ILQCATJHANCNFSM4H6YVIFA.

guolihong commented 4 years ago

Thank you very much for your help!

---Original--- From: "shenhai1895"notifications@github.com Date: Wed, Jul 31, 2019 10:15 AM To: "xmengli999/H-DenseUNet"H-DenseUNet@noreply.github.com; Cc: "Comment"comment@noreply.github.com;"guolihong"2497255426@qq.com; Subject: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

You could use the liver_res predicted by the model as the mask. Like this

mask = liver_res

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: guolihong notifications@github.com 发送时间: Tuesday, July 30, 2019 7:50:43 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

After commenting the part of loading mask,what do you change for preserving results in test.py?

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24J5NT3SGEES4KMTRFLQCATJHA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3DWXWI#issuecomment-516385753, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24KZHIY5TVE5CMZB3ILQCATJHANCNFSM4H6YVIFA. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

guolihong commented 4 years ago

Thank you!But without masks,I use the model author replied and the dice of tumor is only 0.23,which is so low.Have you reproduced the results in the article?

---Original--- From: "shenhai1895"notifications@github.com Date: Wed, Jul 31, 2019 10:15 AM To: "xmengli999/H-DenseUNet"H-DenseUNet@noreply.github.com; Cc: "Comment"comment@noreply.github.com;"guolihong"2497255426@qq.com; Subject: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

You could use the liver_res predicted by the model as the mask. Like this

mask = liver_res

发送自 Windows 10 版邮件https://go.microsoft.com/fwlink/?LinkId=550986应用


发件人: guolihong notifications@github.com 发送时间: Tuesday, July 30, 2019 7:50:43 PM 收件人: xmengli999/H-DenseUNet H-DenseUNet@noreply.github.com 抄送: shenhai1895 shenhai1895@hotmail.com; Author author@noreply.github.com 主题: Re: [xmengli999/H-DenseUNet] Could you please update the code you use about generating livermask? (#39)

After commenting the part of loading mask,what do you change for preserving results in test.py?

― You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/xmengli999/H-DenseUNet/issues/39?email_source=notifications&email_token=AE2Q24J5NT3SGEES4KMTRFLQCATJHA5CNFSM4H6YVIFKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3DWXWI#issuecomment-516385753, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AE2Q24KZHIY5TVE5CMZB3ILQCATJHANCNFSM4H6YVIFA.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

anxingle commented 4 years ago

x = imgs_test.shape[0] y = imgs_test.shape[1] z = imgs_test.shape[2] right_cols = int(min(z, maxi[2] + 10) - img_cols) left_cols = max(0, min(mini[2] - 5, right_cols)) right_cols = int(z - img_cols) left_cols = 0 score = np.zeros((x, y, z, num), dtype='float32') score_num = np.zeros((x, y, z, num), dtype='int16') 发送自 Windows 10 版邮件<https://go.microsoft.com/fwlink/?LinkId=550986>应用

I wonder if x, y, z is maxi in "load liver mask" part(num is referenced before assignment)? So, what is "mini"? # load liver mask mask, mask_header = load(args.liver_path + str(id) + '-ori.nii') mask[mask==2]=1 mask = ndimage.binary_dilation(mask, iterations=1).astype(mask.dtype) index = np.where(mask==1) mini = np.min(index, axis = -1) maxi = np.max(index, axis = -1)