Code Monkey home page Code Monkey logo

Comments (12)

cutright avatar cutright commented on September 12, 2024

Can you be more specific? On the import screen?

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

After I import all plans they are may be 2600 I do not know .....
The I try to use the menu from thr menu bar. ...
it seams too much data to proces ..

from dvh-analytics.

cutright avatar cutright commented on September 12, 2024

Is it better after relaunching the application? Perhaps the import screen didn't release the memory it used.

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

When I add new Institutional ROI - It freezess . with Not Responding - and after about 1 or 2 minutes - the results is refreshed and done

from dvh-analytics.

cutright avatar cutright commented on September 12, 2024

I'm really unclear of the situation, can you provide some screenshots?

It sounds like you did a blind import of everything, and now you're editing the ROI Map after the import?

from dvh-analytics.

cutright avatar cutright commented on September 12, 2024

If my hunch in the last message is correct, the slow down is in the code below.

It's definitely not efficient. My guess is that updating one ROI at a time is biggest contributor.

class RemapROIWorker(Thread):
"""
Create a thread to update the SQL DB with roi map changes
"""
def __init__(self, roi_map, remap_all=False):
"""
:param roi_map: roi map object
:type roi_map: DatabaseROIs
:param remap_all: If true, remap entire database
:type remap_all: bool
"""
Thread.__init__(self)
self.roi_map = roi_map
self.remap_all = remap_all
self.start_time = datetime.now()
self.start() # start the thread
def run(self):
if self.remap_all:
physician_to_map = self.roi_map.get_physicians()
variations_to_update = {}
else:
physician_to_map = self.roi_map.physicians_to_remap
variations_to_update = self.roi_map.variations_to_update
with DVH_SQL() as cnx:
physicians_in_db = cnx.get_unique_values("plans", "physician")
physician_to_map = [
p for p in physician_to_map if p in physicians_in_db
]
physician_counter = 0
physician_count = len(
list(variations_to_update) + physician_to_map
)
# Partial physician remaps
for physician, variations in variations_to_update.items():
msg = [
"Physician (%s of %s): %s"
% (physician_counter + 1, physician_count, physician),
int(100 * physician_counter / physician_count),
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_1_info", msg=msg
)
variation_count = len(variations)
variation_counter = 0
for variation in variations:
variation_frac = variation_counter / variation_count
msg = [
"Physician (%s of %s): %s"
% (physician_counter + 1, physician_count, physician),
int(
100
* (
physician_counter / physician_count
+ variation_frac / physician_count
)
),
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_1_info", msg=msg
)
msg = [
"ROI Name (%s of %s): %s"
% (variation_counter + 1, variation_count, variation),
int(100 * variation_counter / variation_count),
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_2_info", msg=msg
)
msg = "Elapsed Time: %s" % get_elapsed_time(
self.start_time, datetime.now()
)
wx.CallAfter(
pub.sendMessage, "roi_map_update_elapsed_time", msg=msg
)
variation_counter += 1
self.update_variation(variation, physician, cnx)
physician_counter += 1
# Full Physician remaps
for physician in physician_to_map:
condition = "physician = '%s'" % physician
uids = cnx.get_unique_values(
"Plans", "study_instance_uid", condition
)
if uids:
condition = "study_instance_uid in ('%s')" % "','".join(
uids
)
variations = cnx.get_unique_values(
"DVHs", "roi_name", condition
)
msg = [
"Physician (%s of %s): %s"
% (physician_counter + 1, physician_count, physician),
int(100 * physician_counter / physician_count),
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_1_info", msg=msg
)
variation_count = len(variations)
variation_counter = 0
for variation in variations:
variation_frac = variation_counter / variation_count
msg = [
"Physician (%s of %s): %s"
% (
physician_counter + 1,
physician_count,
physician,
),
int(
100
* (
physician_counter / physician_count
+ variation_frac / physician_count
)
),
]
wx.CallAfter(
pub.sendMessage,
"roi_map_update_gauge_1_info",
msg=msg,
)
msg = [
"ROI (%s of %s): %s"
% (
variation_counter + 1,
variation_count,
variation,
),
int(100 * variation_frac),
]
wx.CallAfter(
pub.sendMessage,
"roi_map_update_gauge_2_info",
msg=msg,
)
msg = "Elapsed Time: %s" % get_elapsed_time(
self.start_time, datetime.now()
)
wx.CallAfter(
pub.sendMessage,
"roi_map_update_elapsed_time",
msg=msg,
)
variation_counter += 1
self.update_variation(variation, physician, cnx)
physician_counter += 1
msg = [
"Physician (%s of %s): %s"
% (physician_counter, physician_count, physician),
100,
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_1_info", msg=msg
)
msg = [
"ROI (%s of %s): %s"
% (variation_counter, variation_count, variation),
100,
]
wx.CallAfter(
pub.sendMessage, "roi_map_update_gauge_2_info", msg=msg
)
sleep(0.2)
wx.CallAfter(pub.sendMessage, "roi_map_close")
def update_variation(self, variation, physician, cnx):
variation = clean_name(variation)
new_physician_roi = self.roi_map.get_physician_roi(
physician, variation
)
if new_physician_roi == "uncategorized":
new_institutional_roi = "uncategorized"
else:
new_institutional_roi = self.roi_map.get_institutional_roi(
physician, new_physician_roi
)
condition = "roi_name = '%s'" % variation
roi_uids = cnx.get_unique_values(
"DVHs", "study_instance_uid", condition
)
if roi_uids:
condition = "physician = '%s' and study_instance_uid in ('%s')" % (
physician,
"','".join(roi_uids),
)
uids = cnx.get_unique_values(
"Plans", "study_instance_uid", condition
)
if uids:
for i, uid in enumerate(uids):
condition = (
"roi_name = '%s' and study_instance_uid = '%s'"
% (variation, uid)
)
cnx.update(
"dvhs", "physician_roi", new_physician_roi, condition
)
cnx.update(
"dvhs",
"institutional_roi",
new_institutional_roi,
condition,
)
roi_type = self.roi_map.get_roi_type(
physician, new_physician_roi
)
if new_physician_roi != "uncategorized":
cnx.update("dvhs", "roi_type", roi_type, condition)

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

Yes that it is what I did :)

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

I do not need ROI at that moment . I need Plans and WHat I do is to make Plan Catalog for ML . I have Data Base another DVHdatabase and also measurments results of the plans ... I do not have the plan geometries .. Now I have this also .... :)

from dvh-analytics.

cutright avatar cutright commented on September 12, 2024

It seems we have very similar interests. Unfortunately (Fortunately?), development of the next evolution of DVH Analytics is taking up most of my time. I'll try to do some research to see if I can speed this up given the architecture constraints.

In the mean time, if you do need the ROI map and if you're code savvy, it might be quicker (or at least less clicking and waiting in the GUI) to manually edit the (.roi file in ~/Apps/dvh_analytics/preferences) and then Remap the entire database. Note that this is physician dependent too, so maybe best to set all of your plans to the same physician.

"<institutional_roi>":"<physician_roi>":"<variation_1>","<variation_2>","<variation_3>"

For example:

"brainstem":"brainstem":"brainstem","brain stem","study brain stem"
"bronchus large":"bronchus large":"bronchus large"
"bronchus smaller airways":"bronchus smaller airways":"bronchus smaller airways"
"cauda equina":"cauda equina":"cauda equina"

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

Yes I will plan to do this.

I was wondering if it is posible to get the dose Map for the ISODOSE . as a Structure - AND then to map this with real one. .

I Have some knowlage on python. and C# and database .. Actualy the work flow here im my center of the physicist is design for colecting data .... ...
I use on ML Model to predict gamma Pass of any plan that we created ...
actualy it is very good ...

Thank you for you help it is realy helpful to speed up the catalog :)

from dvh-analytics.

cutright avatar cutright commented on September 12, 2024

With the above commit, I only observed a ~5% speed improvement by updating all columns at once per row (with 70 rows in the DVHs table).

Updating multiple rows at once appears to be fairly complicated and I'm wary of creating temporary tables. Ultimately, the slowness is due to poor SQL design on my part.

I'm happy to accept a pull request if someone else sees a fix, but I don't see a good solution.

from dvh-analytics.

bozhikovstanislav avatar bozhikovstanislav commented on September 12, 2024

I can try to fix the designe of the SQL . this mean that the sql quearyes also must be fixed ... I can give it a try :)

from dvh-analytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.