Help Setup Orthanc LUA Script Write to Disk

189 views
Skip to first unread message

Vitor Dalto

unread,
Sep 21, 2018, 5:01:01 PM9/21/18
to Orthanc Users
Hello,

I have installed Orthanc on a Win7 PC today. It's working great over my home PACS. I could send my US studies to it from my Osirix. 

Now I'm trying to make the lua script work, but I couldn't.

I Hope if anyone can help me.  The major problem is that I don't know how to check where the error is.


PART of CONFIG FILE:

// List of paths to the custom Lua scripts that are to be loaded
// into this instance of Orthanc
"LuaScripts" : ["C:\\Orthanc\\Script\\writetodisk.lua" ],
 
LUA CONTENT:

TARGET = 'C:\\ExamesUS'

function ToAscii(s)
   return s:gsub('[^a-zA-Z0-9-/-: ]', '_')
end

function OnStableSeries(seriesId, tags, metadata)
   print('This series is now stable, writing its instances on the disk: ' .. seriesId)

   local instances = ParseJson(RestApiGet('/series/' .. seriesId)) ['Instances']
   local patient = ParseJson(RestApiGet('/series/' .. seriesId .. '/patient')) ['MainDicomTags']
   local study = ParseJson(RestApiGet('/series/' .. seriesId .. '/study')) ['MainDicomTags']
   local series = ParseJson(RestApiGet('/series/' .. seriesId)) ['MainDicomTags']

   for i, instance in pairs(instances) do
      local path = ToAscii(TARGET .. '/' .. 
                              patient['PatientID'] .. ' - ' .. patient['PatientName'] .. '/' ..
                              study['StudyDate'] .. ' - ' .. study['StudyDescription'] .. '/' ..
                              series['SeriesDescription'])

      -- Retrieve the DICOM file from Orthanc
      local dicom = RestApiGet('/instances/' .. instance .. '/file')

      -- Create the subdirectory (CAUTION: For Linux demo only, this is insecure!)
      os.execute('mkdir -p "' .. path .. '"')

      -- Write to the file
      local target = assert(io.open(path .. '/' .. instance .. '.dcm', 'wb'))
      target:write(dicom)
      target:close()
   end
end


LOGFILE:

W0921 17:52:18.645600 main.cpp:1305] Orthanc version: 1.4.2

W0921 17:52:18.655600 OrthancInitialization.cpp:169] Scanning folder "Configuration" for configuration files

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\dicomweb.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\mysql.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\orthanc.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\postgresql.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\serve-folders.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\webviewer.json"

W0921 17:52:18.655600 OrthancInitialization.cpp:121] Reading the configuration from: "Configuration\worklists.json"

W0921 17:52:18.735600 main.cpp:655] Loading plugin(s) from: Configuration\../Plugins/

W0921 17:52:18.755600 PluginsManager.cpp:269] Registering plugin 'worklists' (version 1.4.2)

W0921 17:52:18.755600 PluginsManager.cpp:168] Sample worklist plugin is initializing

W0921 17:52:18.755600 PluginsManager.cpp:168] Worklist server is disabled by the configuration file

W0921 17:52:18.835600 PluginsManager.cpp:269] Registering plugin 'dicom-web' (version 0.5)

W0921 17:52:18.835600 PluginsManager.cpp:168] URI to the DICOMweb REST API: /dicom-web/

W0921 17:52:18.835600 PluginsManager.cpp:168] URI to the WADO-URI API: /wado

W0921 17:52:18.855600 PluginsManager.cpp:269] Registering plugin 'mysql-index' (version 1.1)

W0921 17:52:18.865600 PluginsManager.cpp:168] The MySQL index is currently disabled, set "EnableIndex" to "true" in the "MySQL" section of the configuration file of Orthanc

W0921 17:52:18.885600 PluginsManager.cpp:269] Registering plugin 'mysql-storage' (version 1.1)

W0921 17:52:18.905600 PluginsManager.cpp:168] The MySQL storage area is currently disabled, set "EnableStorage" to "true" in the "MySQL" section of the configuration file of Orthanc

W0921 17:52:18.915600 PluginsManager.cpp:269] Registering plugin 'postgresql-index' (version 2.2)

W0921 17:52:18.915600 PluginsManager.cpp:168] The PostgreSQL index is currently disabled, set "EnableIndex" to "true" in the "PostgreSQL" section of the configuration file of Orthanc

W0921 17:52:18.925600 PluginsManager.cpp:269] Registering plugin 'postgresql-storage' (version 2.2)

W0921 17:52:18.925600 PluginsManager.cpp:168] The PostgreSQL storage area is currently disabled, set "EnableStorage" to "true" in the "PostgreSQL" section of the configuration file of Orthanc

W0921 17:52:18.995600 PluginsManager.cpp:269] Registering plugin 'web-viewer' (version 2.4)

W0921 17:52:18.995600 PluginsManager.cpp:168] Initializing the Web viewer

W0921 17:52:18.995600 PluginsManager.cpp:168] Web viewer using 2 threads for the decoding of the DICOM images

W0921 17:52:18.995600 PluginsManager.cpp:168] Storing the cache of the Web viewer in folder: C:\Orthanc\WebViewerCache

W0921 17:52:19.015600 PluginsManager.cpp:168] Web viewer using a cache of 100 MB

W0921 17:52:19.015600 PluginsManager.cpp:168] Using GDCM instead of the DICOM decoder that is built in Orthanc

W0921 17:52:19.025600 PluginsManager.cpp:269] Registering plugin 'wsi' (version 0.5)

W0921 17:52:19.025600 PluginsManager.cpp:168] The whole-slide imaging plugin will use at most 4 threads to transcode the tiles

W0921 17:52:19.165600 PluginsManager.cpp:269] Registering plugin 'osimis-web-viewer' (version 1.1.1.0-08acf7b2)

W0921 17:52:19.165600 PluginsManager.cpp:168] Initializing the Web viewer

W0921 17:52:19.175600 PluginsManager.cpp:168] Using GDCM instead of the DICOM decoder that is built in Orthanc

W0921 17:52:19.185600 PluginsManager.cpp:269] Registering plugin 'serve-folders' (version 1.4.2)

W0921 17:52:19.195600 PluginsManager.cpp:168] ServeFolders: Empty configuration file: No additional folder will be served!

W0921 17:52:19.195600 OrthancInitialization.cpp:1050] SQLite index directory: "C:\Orthanc"

W0921 17:52:19.205600 OrthancInitialization.cpp:1120] Storage directory: "C:\Orthanc"

W0921 17:52:19.205600 HttpClient.cpp:739] HTTPS will use the CA certificates from this file: Configuration

W0921 17:52:19.215600 LuaContext.cpp:103] Lua says: Lua toolbox installed

W0921 17:52:19.215600 LuaContext.cpp:103] Lua says: Lua toolbox installed

W0921 17:52:19.215600 ServerContext.cpp:299] Disk compression is disabled

W0921 17:52:19.215600 ServerIndex.cpp:1449] No limit on the number of stored patients

W0921 17:52:19.215600 ServerIndex.cpp:1466] No limit on the size of the storage area

W0921 17:52:19.215600 ServerContext.cpp:164] Reloading the jobs from the last execution of Orthanc

W0921 17:52:19.215600 JobsEngine.cpp:281] The jobs engine has started with 2 threads

W0921 17:52:19.215600 main.cpp:848] DICOM server listening with AET SERVER on port: 4242

W0921 17:52:19.215600 MongooseServer.cpp:1088] HTTP compression is enabled

W0921 17:52:19.225600 MongooseServer.cpp:1002] HTTP server listening on port: 8042 (HTTPS encryption is disabled, remote access is not allowed)

W0921 17:52:19.225600 main.cpp:667] Orthanc has started


------

Thank you in advance.

I hope you can helpme.


Vitor Dalto

unread,
Sep 21, 2018, 5:02:28 PM9/21/18
to Orthanc Users
File Atached 
Maybe it's easier to you guys.
writetodisk.lua

Sébastien Jodogne

unread,
Sep 22, 2018, 2:46:31 AM9/22/18
to Orthanc Users
Hello,

According to the logs you provided, your Lua file is not loaded by Orthanc.

You have visibly not modified the proper configuration file.

HTH,
Sébastien-

Vitor Dalto

unread,
Sep 22, 2018, 1:17:07 PM9/22/18
to Sébastien Jodogne, Orthanc Users
Hi, 
Thanks for the reply.

I have replaced the config file and now it’s working. 

The script was creating a “- p” folder and I deleted this part also. 

Now everything is doing OK.

Sebastian, do you know if Orthanc can generate print files ?
Other solutions like “k-pacs” and “microdicom” can export to windows printers. 
It’s possible ?

Thanks 
--
Vitor Faeda Dalto
Medico Radiologista - área de atuação: Músculo-esquelética.
Doutorado em medicina pelo departamento de Ortopedia da FMRP-USP
R.V. SERVIÇOS MÉDICOS S/S LTDA

Benoît Crickboom

unread,
Sep 24, 2018, 3:28:21 AM9/24/18
to Vitor Dalto, Orthanc Users
Reply all
Reply to author
Forward
0 new messages