Author Archives: bloggyadmin

Using the column name in your file naming convention in Access OLE Export / SQL Blob Export

When you export images and files using Access OLE Export / SQL Blob Export and each row of your table or result set contains multiple columns that contain the blob data e.g.

you could previously only use the column index in the file naming convention to identify the source column of the exported file e.g.

which would then name the exported files this way:

Files with the suffix 0002 indicates that it was exported from the 2nd column (ThumbnailPhoto), and 0003 from the 3rd column (LargePhoto).

From version 3.17 onwards, you can now use the column name in the naming convention, using the <%columnname%> tag e.g.

The exported files are then named this way:

which is more meaningful.

 

Using the column name in your file naming convention in SQL Image Viewer

In SQL Image Viewer 10.2, we’ve added a new option to the system values for your file naming convention.

Using this example:

Each row contains 2 binary-type columns.  We can name our exported images using the ProductPhotoID column, but to identify the source column for the images, we could previously only use the column index

resulting in file names like these:

The first part of the file name is the ProductPhotoID value, formatted to 4 digits, and the second part is the column index (columns 2 and 3).

From SQL Image Viewer 10.2 onwards, you can now use the column name as part of the naming convention.

which is used to name the exported files

You can select this new option (columnname) in the File Naming Convention page.

If you want to use a different value for the column name, simply use the alias syntax applicable to your database engine.  For SQL Server, this would be using the AS option e.g.

How to view image data type in SQL Server

The image data type in SQL Server is frequently used to store variable length binary data.  It does not have to store only ‘images’, though most people associate that data type with images.

You may occasionally need to view the type of data that’s stored, but SQL Server Management Studio can only display the binary representation of the data (we’re using the AdventureWorks sample database here).

SQL Image Viewer is one tool that can display the image directly in the result set.

Interesting points to note:

  • the image format was never provided.  SQL Image Viewer can read the binary data and determine the image format itself.  It recognizes png, gif, jpg, tiff, bmp, wmf, emf, dicom, and raw camera formats.
  • details of the image like size and resolution are provided automatically

Though its name might suggest otherwise, SQL Image Viewer doesn’t just support ‘images’.  It recognizes a wide variety of file formats, including Microsoft Office documents, OpenOffice documents, PDF, epub, multimedia files (avi, wav, mp3, mp4, svg, swf, flv, mkv, webm, m4v, mov, 3gp), and compressed archives (zip, 7zip, rar, bzip2, gzip).

For PDFs, SQL Image Viewer is able to display a thumbnail of the first page, and also the number of pages in the file.

Once retrieved, you can export the binary data.  You can export them to a spreadsheet:

or simply export them as individual files:

You can name the files using values from other columns.  You can also convert the exported images to other formats:

For images that contain EXIF values, you can view these values using the internal viewer:

SQL Image Viewer supports Oracle, PostgreSQL, MySQL, MariaDB, Microsoft Access, SQLite and ODBC supported databases.

Thus, you can easily view the data that’s stored in

  • binary and varbinary columns in Oracle databases
  • bytea columns in PostgreSQL databases
  • binary and varbinary columns in MySQL and MariaDB databases
  • binary and varbinary columns in Microsoft Access databases
  • OLE-Object columns in Microsoft Access databases

Download a free 14-day trial now and see how SQL Image Viewer can make working with image data types in SQL Server so much easier.

Using the newer Excel format (xlsx) in your exports

When SQL Image Viewer first supported exporting your result sets to Excel spreadsheets, it only supported the older .xls format.

Since version 9.7 (released in December 2019), the newer Excel format (.xlsx) is now supported.  However, because SQL Image Viewer uses your last export settings when you choose the Excel file name, you may still be using the older .xls format.

To export your data and images to the new Excel format, simply change the file extension from xls to xlsx.

For new users, and users who have never exported to Excel previously, the default extension used is xlsx,  so no action is required on your part to use the new Excel format.

The main advantage in using the xlsx format is that the maximum number of rows in your worksheet increases to 1,048,576 from 65,536 rows.

 

DICOM Search – improved DICOM view (preview)

In the latest iteration of DICOM Search, we can now display your search results in a patient/study/series listing this way:

  • thumbnails are now displayed in the patient/study/series listing

This allows you to easily view the image without having to open it in the main viewing area.

  • you can filter on multiple values

In the above example, DICOM Search will display the images belonging to any patient/study/series containing the word brain OR rubo.

  • similarly, you can also filter on multiple values on the tag values

In the above example, only tags containing the word patient or physi are displayed.

You can now also display multiple images in the DICOM viewer.  You can adjust the position and size of each image panel to your requirements.  For e.g. if you are displaying 3 images, this could be one layout:

or you could lay them out this way:

You can open as many image panels as you require, limited primarily by the size of your display.

When you open multiple image panels, the DICOM details are also displayed for each image.  In the above example. the patient information would be displayed this way:

Similarly, the DICOM tag values found in each of the image are displayed this way:

If you apply a search filter, then only the tags matching the filter are displayed for all the images.

In the image viewer, there is now a magnification layer option.  Say you opened the following image:

You now have the option to magnify a part of the image, and also choose the magnification level and magnification area.

We hope to release DICOM Search early next month.  If you would like to have early access to the product and give it a try, please drop us a line at support@yohz.com.  We welcome any feedback you may have.

Merge or combine TIFF files

We had a user who recently asked if SQL Blob Export is able to merge or combine the extracted single-page TIFF files from her database into multi-page TIFF files.  This feature isn’t built-in, but we have provided an external command line application (MergeTiff) that you can freely use to perform the same task.

You can use MergeTiff on any tif files, including those extracted using SQL Image Viewer, SQL Blob Export, and Access OLE Export.  It is important that the extracted files use names that group the pages into the right order.

For e.g. the default naming convention for exported files in SQL Image Viewer is row and column index, so assuming each row in your result set only had 1 blob column, your exported files would be named this way:

0001_0001.tif
0002_0001.tif
0003_0001.tif

This isn’t going to help MergeTiff determine how to group the files.  What you need is a ‘grouping’ value e.g. say a CustomerID column that identifies the customer each image belongs to.  We then use this naming convention in SQL Image Viewer/ SQL Blob Export/ Access OLE Export:

<CustomerID>_<%row:0000%>

and our exported files may be named this way:

A00123_0001.tif
A00123_0002.tif
A00123_0003.tif
C72186_0006.tif
D12472_0007.tif
E88822_0004.tif
E88822_0005.tif

In this way, we know that for customer A00123, we need to merge 3 files, for customer E88822, we need to merge 2 files, and so on.

To use MergeTiff, you need to provide at least 1 parameter:

  • the search pattern for the files to process using the -i  parameter e.g.

MergeTiff.exe -i “g:\exported images\*.tif” 

Other parameters supported by MergeTiff:

-o

this is the output folder to store the merged files.  If not provided, the merged files will be stored in the same folder as the source files.  If you want to store the merged files in a different folder, you would need to provide the -o parameter e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -o “g:\exported images\merged\”

-d

this is the delimiter that the source file name uses to separate elements, default value is _

In our example, our file name elements use the underscore character e.g. _.  You might use another symbol e.g.

A00123-0001.tif
A00123-0002.tif
A00123-0003.tif
E88822-0004.tif

In this case, you need to provide the -d parameter and the delimiter character e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -o “g:\exported images\merged\” -d “-“

-g

this is the grouping element index, default value is 1.  In our example, the grouping element is the first element i.e. all the characters before the first delimiter i.e.

A00123
E88822
C72186
D12472
E88822

If instead our file named had been named this way:

scanneddocsA00123_invoice1005_A00123_0001.tif
scanneddocsA00123_invoice1005_A00123_0002.tif
scanneddocsA00123_invoice1006_A00123_0003.tif
scanneddocsC72186_invoice1008_C72186_0006.tif
scanneddocsD12472_invoice2010_D12472_0007.tif

and we still wanted to merge all documents belonging to the same customer, then our grouping element is the 3rd element, and we would need to use the -g parameter e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -o “g:\exported images\merged\” -g 3

-n

this is the naming element index, default value is 1.  Following on from the above example, supposing we merge our files by invoice number instead of customer code, we would need to use both the -g and -n parameters e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -o “g:\exported images\merged\” -g 2 -n 2

-ow

use this parameter to overwrite any existing files of the same name

If you want MergeTiff to overwrite any existing files, use the -ow parameter e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -ow

-r

use this parameter to also process files in the input path subfolders

To process files recursively beneath the input path, use the -r parameter e.g.

MergeTiff.exe -i “g:\exported images\*.tif” -r

You can download MergeTiff from here.

DICOM Search walk-through (preview)

We’ll do a walk-through on how to index your DICOM files and how to retrieve and display the images you need.

We start by first creating a library in DICOM Search, and selecting the Add/update images from folders option.

We then enter the file search pattern which will be used to locate our DICOM files.  Here, we’ll create thumbnails of our files, and enter the database file name to store the tag values and thumbnails in.

DICOM Search will then start processing the files and report the status as it goes along.

Once done, we can now run queries on the database.  In this example, we want to retrieve all MRI images where the study description contains the word head or torso.

At this point, you must be wondering how are we to remember the group and element values for each of the tags we want to search on.  You don’t have to remember those values.  Pressing F2 will bring up a tags window where you can search for any tag values by description.

E.g. if we search for modal, we can see all the tag values for modality.

Likewise, if we search for study, we can see the tags containing the word study.

When we run our query, all images matching our search criteria are returned.

Depending on our query, we may choose to return only the tag values we are interested in seeing, or in our example. all of the tag values because we entered

SELECT * …

DICOM Search offers an alternative view to display the images returned by your query.  This is the DICOM results viewer.

On the left, the query results are grouped by patient, study, series, and and related images.

You can display any of the image file in the main area simply by selecting it here.  DICOM Search will display the frames of the images at the top, and the selected frame in the main area.  You can play the sequence of images, display a single frame, view the transition from one frame to another and more in this area.

On the right, the values of the DiCOM tags are listed.  There is a patient specific tab that displays the patient data together with some image context tags

and a Tags tab that displays all the tag values found in the image.

If you have any suggestions on how we can improve on this new view, please do drop us a line at support@yohz.com.  Thank you.

See also:

Incorrectly extracted files in Access OLE Export/SQL Blob Export

Access OLE Export / SQL Blob Export may sometimes extract items that appear to be wrong.  For e.g. it might extract an expected PDF file as an image file.  To troubleshoot such issues, we need your help in sending us the data exactly as stored in your database to us for further investigation.

One way to extract the data is to use SQL Image Viewer.  Once installed, connect to the same database you were trying to extract your items from, and run your query to select the wrongly extracted item(s).

Select the item you’re having problems with, right click to bring up the context menu, and select the View as hex option.

SQL Image Viewer will display the selected item in a hex viewer.  Click on the Save button to save the raw data to a file.

and send us that file at support@yohz.com.  Having the raw data to work with will help us immensely to determine why Access OLE Export / SQL Blob Export appears to be extracting your files wrongly.

 

DICOM Search – querying the database (preview 2)

Once DICOM Search has indexed the DICOM tags in your images, you can run queries against the tags table.  Selecting everything from the tags table, while possible, isn’t very useful and is very slow.

The reason is because there are over 2800 fields, and DICOM Search will struggle to maintain and display that many columns.  Thus, it is recommended that you select only the fields you are interested in.

You can quickly see which fields are available in your database by pressing F2 when in the SQL editor to bring up the Tags and Fields window.

Clicking on any of the tag values will add that value to the SQL editor area, so you do not need to manually enter the tag name.  In addition to the DICOM tags, there are also additional fields that DICOM Search populates in the tags table, as listed in the Field names tab.

In addition to your key fields, the other fields are used by DICOM Search to maintain a record of the processed images.  For the users, the useful fields are ds_thumbnail and ds_filenameds_thumbnail stores a thumbnail of the image and ds_filename stores the location of the image file when exported from your database, or when processed from your folder.

If the listed file name is present on your computer, you can open the image file in your DICOM viewer by double-clicking on the file name in DICOM Search.

Please see this post on how to index and extract images from your database to your computer using DICOM Search, and also how to add thumbnails to the tags database.

 

SQL syntax

The tag values are stored in a SQLite database, so you will use the SQLite SQL syntax to query the database.  In our example, our key fields are patientID and studyID, so we will always select those columns in case we want to query the source database.  We also select the ds_thumbnail and ds_filename columns to view the image thumbnail, and also have a link to the actual image.

Here are some examples of the types of queries you can run:

  • searching text values
    E.g. the Patient Name (tag group and element 0010,0010):SELECT patientID, studyID, ds_thumbnail, ds_filename FROM tags WHERE [00100010] = ‘Rubo’
  • searching for part of a text value
    E.g. to return all images where the patient name starts with Rubo:SELECT patientID, studyID, ds_thumbnail, ds_filename FROM tags WHERE [00100010] LIKE ‘Rubo%’E.g. to return all images where the patient name contains the word Rubo:SELECT patientID, studyID, ds_thumbnail, ds_filename FROM tags WHERE [00100010] LIKE ‘%Rubo%’

    E.g. to retrieve all images there the patient name ends with Rubo:

    SELECT patientID, studyID, ds_thumbnail, ds_filename FROM tags WHERE [00100010] LIKE ‘%Rubo’

  • searching date values
    E.g. the Study Date tag (tag group and element 0008,0020) for all studies made between Jan 1 1993 and Jan 1 1994:SELECT patientID, studyID, ds_thumbnail, ds_filename, [00080020] FROM tags WHERE [00080020] >= ‘1993-01-01’ AND [00080020] < ‘1994-01-01’Key point is you need to always enter the value you want to search for using yyyy-mm-dd format (year-month-date)
  • searching time values
    E.g. the Study Time tag (tag group and element 0008,0030), for all studies made between 1 PM and 2 PM.SELECT patientID, studyID, ds_thumbnail, ds_filename, [00080030] FROM tags WHERE [00080030] >= ’13:00′ AND [00080030] < ’14:00′Key point is you need to always enter the value you want to search for using hh:mm:ss format (hour:minutes:seconds).
  • searching numbers
    You can use all the usual equality and comparison symbols for numbers e.g. =, >, >=, <, <=E.g. the Intervention Drug Dose tag (tag group and element 0018,0028), where the value is greater than 25SELECT patientID, studyID, ds_thumbnail, ds_filename, [00180028] FROM tags WHERE [00180028] > 25

You can combine multiple conditions using the AND and OR operators e.g.

SELECT patientID, studyID, ds_thumbnail, ds_filename, [00080030] FROM tags WHERE ([00080020] >= ‘1993-01-01’ AND [00080020] < ‘1994-01-01’ AND [00080030] >= ’13:00′ AND [00080030] < ’14:00′) OR ([00100010] = ‘Rubo’)

To sort the results, use the ORDER BY option, and specify the field to sort by e.g. to sort the results by patient name (tag group and element

SELECT patientID, studyID, ds_thumbnail, ds_filename, [00080030] FROM tags WHERE ([00080020] >= ‘1993-01-01’ AND [00080020] < ‘1994-01-01’) ORDER BY [00100010]

To sort in descending order, add the DESC option after the field name e.g.

SELECT patientID, studyID, ds_thumbnail, ds_filename, [00080030] FROM tags WHERE ([00080020] >= ‘1993-01-01’ AND [00080020] < ‘1994-01-01’) ORDER BY [00100010] DESC

To limit the number of rows returned, use the LIMIT option.  For e.g. to retrieve the first 30 rows where the Intervention Drug Dose value is greater than 25, sorted by that field in descending order

SELECT patientID, studyID, ds_thumbnail, ds_filename, [00180028] FROM tags WHERE [00180028] > 25 ORDER BY [00180028] DESC LIMIT 30

See also:

DICOM Search – libraries (preview 1)

In DICOM Search, your DICOM images are organized into libraries.

You can populate each library with images from one or more databases, or from files on your computer.

Retrieving and indexing images from a database

DICOM Search can connect to PostgreSQL, SQL Server, Oracle, MariaDB, MySQL, and most popular database engines.  First, enter your connection details to connect to the database you want to process images from.

Enter the query to retrieve your images, together with the key fields used to uniquely identify the image.

You will then need to let DICOM Search know which are the key fields.

In our example, the patientID and studyID are the key fields.  Note that the key fields are for your own reference – when you query the tags database, the key fields are your link to the records in your source database.  When you want to extract the images or additional information from the source database, the key field values will help you in retrieving the relevant images.

DICOM Search will extract all the standard DICOM tag values and store them in a SQLite database.  You specify the name of this database file in the Tags database file name.

Indexing images from files on your computer

You can also index DICOM images if they are stored as files on your computer.   Enter the file paths and file search patterns to locate your DICOM files.  You can enter multiple values to search in.

 

Thumbnails

By default, only DICOM tag values are stored in the database e.g.

You can have DICOM Search create thumbnails for each of the image you process from your database or folder.

To create a thumbnail, select the Create thumbnail images option and enter the size of the thumbnail to create.

Once the thumbnails have been created, they will be displayed in a column named ds_thumbnail and can be displayed in DICOM Search together with the image tag values.

Exporting the images from your database

DICOM Search also helps you export your DICOM images from your database and store it in a folder on your computer.  To export the images, select the Extract images to folder option.

DICOM Search will then extract the images and store the file name in the ds_filename column.  When you run queries against the tags database and select this column, it will be highlighted in blue if the image file exists.  To open the file using your registered DICOM viewer, double click on the file name.

 

See also: