the cell data of dicom browser, for example, patients table, studies table and series table is from the tags of dicom,or the database, but i want to update it temporarily with python
We used to display the raw DICOM data directly in the browser, but things are better now. We use the database to cache raw DICOM data and there are rules (see ctkDICOM*Rule classes) that compute displayed fields from these raw data, which is displayed in the browser.
Still, changing data in the database is not trivial.
One issue is that the database can be requested to be rebuilt by re-indexing the data sets. This typically happens when the database schema is changed, which can occur when you open the database with a newer or older Slicer version. If you just change the data cached in the database then those changes will be lost when the database is rebuilt.
Another issue is that in DICOM it is prohibited to modify a data set. All you can do is to create a modified clone of a data set with a new UID and request hiding of the old data set. You may need to still keep around the old data set so that you can resolve cross-references between data objects.
So, a clear solution would be to create modified clones of the data set (modify the DICOM files) and remove the old version from the database. A somewhat clean solution could be to add a rule that stores a list of field changes and applies that are used for changing the content of displayed fields.
What exactly would you like to achieve?
thanks Lassoan , i want to update the display value not the real value in database or tags, this is my code
dib = slicer.modules.dicom.widgetRepresentation().self().browserWidget.dicomBrowser
db = dib.database()
pm = dib.dicomTableManager().patientsTable().tableView().model()
pm.setData(pm.index(0,1), "1")
it returns false when i excute the setData, the patient table is a instance of QTableView, i think there is a general method to update the cell value
I don’t think you can modify a values in the database by manipulating views. You need to run SQL update statements using Python’s or Qt’s SQLite API. Of course it is just a hack, but if you develop a locked-down custom application then you may be able to ensure that there are no side effects of such low-level manipulations.
OK i will try it thanks