How to compile Orthanc from source code on Ubuntu Server 20.04 LTS

Post Reply
User avatar
LHammonds
Site Admin
Site Admin
Posts: 913
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

How to compile Orthanc from source code on Ubuntu Server 20.04 LTS

Post: # 903Post LHammonds »

------------- WORK-IN-PROGRESS -------------
NOTE: I have not yet done this...still documenting all the steps prior to actually doing it since there are no specific steps for Ubuntu 20.04


Install the prerequisites (listed in alphabetical order):

Code: Select all

sudo apt install build-essential cmake doxygen libboost-all-dev libcharls-dev libcurl4-openssl-dev libdcmtk-dev libgtest-dev libjpeg-dev libjsoncpp-dev liblua5.3-dev libpng-dev libpugixml-dev libsqlite3-dev libssl-dev libwrap0-dev mercurial uuid-dev zlib1g-dev
The following should already be installed on Ubuntu 20.04:

Code: Select all

unzip
python3
locales
Switch to the root user and create the default location for the source code and build:

Code: Select all

sudo su
mkdir -p ~/Orthanc/Build
mkdir -p ~/Orthanc/OrthancServer/ThirdPartyDownloads
Get the latest version of Orthanc from its download page (1.7.2 at the time of this writing).

Code: Select all

wget https://www.orthanc-server.com/downloads/get.php?path=/orthanc/Orthanc-1.7.2.tar.gz -O ~/Orthanc/Orthanc-1.7.2.tar.gz
tar -xzvf ~/Orthanc/Orthanc-1.7.2.tar.gz -C ~/Orthanc --strip-components=1
rm ~/Orthanc/Orthanc-1.7.2.tar.gz
cd ~/Orthanc
Optional - After the 1st time you compile (with auto-download enabled), it will download the following files. The next time you compile, it will not have to download them from the Internet. And if you copy them to a fresh server and compile for the 1st time, it will not need to access the Internet if it finds them already there.

Code: Select all

ls ~/Orthanc/OrthancServer/ThirdPartyDownloads/
boost_1_69_0_bcpdigest-1.5.6.tar.gz
civetweb-1.12-fixed.tar.gz
curl-7.64.0.tar.gz
dcmtk-3.6.5.tar.gz
e2fsprogs-1.44.5.tar.gz
jpegsrc.v9c.tar.gz
jsoncpp-1.8.4.tar.gz
libiconv-1.15.tar.gz
libpng-1.6.36.tar.gz
lua-5.3.5.tar.gz
openssl-1.1.1g.tar.gz
pugixml-1.9.tar.gz
sqlite-amalgamation-3270100.zip
zlib-1.2.11.tar.gz
Compile the source code:

Code: Select all

cd ~/Orthanc/Build
cmake -DSTATIC_BUILD=ON -DALLOW_DOWNLOADS=ON -DUSE_SYSTEM_CIVETWEB=OFF -DUSE_GOOGLE_TEST_DEBIAN_PACKAGE=ON -DDCMTK_LIBRARIES=dcmjpls -DCMAKE_BUILD_TYPE=Release ../OrthancServer/
make
make doc
make install
The install copies files to the following locations:

Code: Select all

/usr/local/sbin/Orthanc
/usr/local/share/orthanc/plugins/
/usr/local/bin/OrthancRecoverCompressedFile
/usr/local/share/doc/orthanc/OrthancPlugin/
/usr/local/include/orthanc/OrthancCPlugin.h
/usr/local/include/orthanc/OrthancCDatabasePlugin.h

User avatar
LHammonds
Site Admin
Site Admin
Posts: 913
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Configuration

Post: # 904Post LHammonds »

Configuration

The goal I am trying to achieve is an installation very similar to how Orthanc is installed from the Debian repository (apt install orthanc)...but with systemd as the service manager rather than init.d.

Create the Orthanc user and group:

Code: Select all

mkdir -p /var/lib/orthanc/db-v6
useradd --home /var/lib/orthanc --comment 'Orthanc Administrator' --user-group orthanc
chown --recursive orthanc:orthanc /var/lib/orthanc
chmod 775 /var/lib/orthanc
chmod 755 /var/lib/orthanc/db-v6

Once compiled and installed, we now need to generate a default configuration file and folders.

Code: Select all

chown --recursive orthanc:orthanc /usr/local/share/orthanc
mkdir -p /var/log/orthanc
chown orthanc:orthanc /var/log/orthanc
chmod 775 /var/log/orthanc
mkdir -p /etc/orthanc
chown orthanc:orthanc /etc/orthanc
chmod 775 /etc/orthanc
Orthanc --config=/etc/orthanc/orthanc.json
chown orthanc:orthanc /etc/orthanc/*.json
chmod 664 /etc/orthanc/*.json
Edit the configuration file and change the following settings (vi /etc/orthanc/orthanc.json):

Code: Select all

  "Name" : "srv-dicom1",
  "StorageDirectory" : "/var/lib/orthanc/db-v6",
  "IndexDirectory" : "/var/lib/orthanc/db-v6",
  "Plugins" : [
    "/usr/local/share/orthanc/plugins"
  ],
  "DicomAet" : "SRVDICOM1",
  "RemoteAccessAllowed" : true,
     "AuthenticationEnabled" : true,
  "RegisteredUsers" : {
    "myadminid" : "myadminpass"
  },
  "DicomModalities" : {
    "PACSProd" : [ "PACSPROD", "192.168.1.200", 104],
Systemd

Code: Select all

touch /lib/systemd/system/orthanc.service
chown root:root /lib/systemd/system/orthanc.service
chmod 644 /lib/systemd/system/orthanc.service
vi /lib/systemd/system/orthanc.service

Code: Select all

[Unit]
Description=Orthanc DICOM Service
After=network.target
After=network-online.target
StartLimitIntervalSec=0

[Service]
Type=simple
Restart=always
RestartSec=1
User=orthanc
ExecStart=/usr/local/sbin/Orthanc --logdir=/var/log/orthanc/ /etc/orthanc/

[Install]
WantedBy=multi-user.target
Enable the service (which creates a link to /etc/systemd/system)

Code: Select all

sudo systemctl enable orthanc
Start the service and check the log (press CTRL+C to stop the realtime observation of the log):

Code: Select all

sudo systemctl start orthanc
sudo tail -f /var/log/orthanc/Orthanc.log

User avatar
LHammonds
Site Admin
Site Admin
Posts: 913
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Transcoding to Jpeg2000 Lossless

Post: # 905Post LHammonds »

Transcoding to Jpeg2000 Lossless

At my location, our destination PACS system stores all incoming images in Jpeg 2000 lessless format. To help alleviate that extra step and save some time on the transmission of the large images over the wide-area network, Orthanc needs to be configured to handle. With version 1.7.0 and above, it has a built-in method to automatically transcode while injesting.

Our source images from modalities are Implicit VR Little Endian and the UID is 1.2.840.10008.1.2
The target Jpeg 2000 Lossless UID will be 1.2.840.10008.1.2.4.90

Related manual pages: Transcoding of DICOM files, Registry of DICOM UIDs
Regarding UID, the DICOM rule is the following: If using lossless (non-destructive) compression, the SOP Instance UID tag *can* stay the same after transcoding. On the other hand, If using lossy (destructive) compression, the SOP Instance UID tag *must* change (for medical traceability, as the information has changed).
Self Note: Need to find a link to the official rule that the above quote is referencing.

Settings to be applied in the orthanc.json:

Code: Select all

  //** 1.2.840.10008.1.2 = Implicit VR Little Endian (Default)
  //"IngestTranscoding" : "1.2.840.10008.1.2",

  //** 1.2.840.10008.1.2.4.90 = JPEG 2000 Compression (Lossless)
  "IngestTranscoding" : "1.2.840.10008.1.2.4.90",
  "DicomLossyTranscodingQuality" : 100
>> IN PROGRESS <<

User avatar
LHammonds
Site Admin
Site Admin
Posts: 913
Joined: Fri Jul 31, 2009 6:27 pm
Are you a filthy spam bot?: No
Location: Behind You
Contact:

Compile NOTE

Post: # 906Post LHammonds »

For a production environment, it might be better to create a .deb install file on a non-production "compiling machine" and transfer that .deb file to the target server and install the .deb file. The main item to consider is that the compiling machine and production server are running the same OS (e.g. Ubuntu Server 20.04 LTS)

On the compiling machine:

Code: Select all

make
make doc
checkinstall --install=no
NOTE: Need to figure out what the result .deb file is named.

Transfer the generated .deb file to the new Orthanc server.

On the Orthanc server, install from the .deb package that was copied to it.

Code: Select all

dpkg -i /tmp/orthanc.deb
To remove the manually installed package (such as prior to installing a newer version):

Code: Select all

dpkg -r orthanc
To remove the configuration files as well:

Code: Select all

dpkg --purge orthanc
NOTE: Need to figure out if the package name matches the name of the .deb file (was assuming orthanc in command-line examples)

Post Reply