Wednesday, February 23, 2011

Creating DICOM Multiframe files (MPEG to DICOM) using dcm4che 2

Hi There!

Long break, uh? Well, dear visitors, I have received a lot of emails asking about multiframe DICOM files. This time we will see an approach on how to build such files. A multiframe DICOM file usually has the meaning of a video file. You can open it in a DICOM viewer and then playback its frames.

To achieve such behavior we will need to know how to extract image frames from a MPEG-2 video file. FFMPEG program is a wonderful tool and complete, cross-platform solution to record, convert and stream audio and video. Also you can get Windows versions of FFMPEG here or here. Once your download is done unpack the FFMPEG file to you root directory and type the following command in your command prompt window:

Wednesday, January 6, 2010

DICOM Multiframe playback using dcm4che 2

Hello visitors,

First of all I'd like to thank you all for every email, tips, comments and mainly the valuable knowledge we have been sharing since I started this simple blog. This time I want to write a tutorial that takes a multiframe DICOM image and then playback it frame by frame. The final result is a Swing Java application where we can watch such file as it was a video file. If you feel it sounds nice so let's go!

If it's your first time here, please I strongly recommend that you read my DICOM to JPEG Conversion post so you can learn how to setup Eclipse and dcm4che toolkit. Then come back to this post and continue to this example tutorial. Let's start! Open your Eclipse IDE and choose File > New > Java Project. Name it DicomExamples. The next step is to create a new class, so right-click the src package and select New > Class. Enter DicomMultiframePlayer for class name and select the main method option. You'll get something like this:


Tuesday, September 1, 2009

CAD-PACS Integration

Hello,

We have published a promising study on the latest Computer Assisted Radiology and Surgery - 24th International Congress and Exhibition in Berlin, Germany. The study presents an open framework that uses dcm4che toolkit for integrating Computer-Aided Diagnosis (CAD) to Picture Archiving and Communication Systems (PACS). It's worth reading! Access AuntMinnie.com for full text and details.

The Brazilian Team (Univesity of São Paulo-USP):

- Paulo Mazzoncini de Azevedo Marques;
- Samuel Covas Salomão;
- Agma Juci Machado Traina;
- Marcelo Ponciano da Silva;
- Alessandra Alaniz Macedo;
- Hugo Cesar Pessotti.


samucs@gmail.com wrote: It's worth reading!
Brazilian team marries lung CAD with PACS

Nearly all computer-aided detection (CAD) systems in clinical use today have a major shortcoming: the need to transfer image data to a separate workstation to run CAD software, with CAD data remaining separate from the PACS images radiologists read in their normal workflow. Researchers from São Paulo may have the answer.


Click here to read more


Kindly regards,

Samuel.

Thursday, March 26, 2009

SAMUCS Web DICOM Viewer

Hello Visitors,

I present you the Samucs Web DICOM Viewer approach. This is a software designed for DICOM image visualization. Since it's a web based program it runs entirely inside your web browser and also makes use of the power of Ajax and Java technologies that increase performance and portability, enhancing flawlessly the user experience.

It's the result of several days of hard work. Here I post the first version of the application for testing and feedback. In addition this software uses the powerful dcm4che toolkit - a collection of open source applications and utilities for the healthcare enterprise. These applications have been also developed in the Java programming, supporting deployment on JDK 1.4 and up.

Features included in this version:
- Remote AE title setup (PACS communication);
- Perform queries on Study, Series and Instance levels;
- Query by filter;
- Query and retrieve images for visualization (C-GET, C-MOVE);
- DICOM header viewer;
- Tools for zooming and image adjustments;
- Different layout views;

To start viewing images right now, first download Samucs Web DICOM Viewer. Then extract the samucs-web.rar to get a WAR file that must be deployed to a Web Server. So download the great Web Server Apache Tomcat. Also, the Java Runtime Environment (JRE) should be running properly on your computer. This application was tested only on Windows Vista environment using Internet Explorer 7 and Firefox 3.0, JRE 6 and Tomcat 6. I strongly recommend Firefox. Linux users I'll try this OS soon :)

The Tomcat install is quite intuitive, just follow the instructions and be sure to set port 8080 for Http. In the end you'll be asked to run Tomcat. Then open your web browser and access http://localhost:8080. If everything is ok you'll see the Tomcat management page. Then click the link Tomcat Manager on the top left corner below the Cat and enter the username and password saved during the installation. Now you are able to deploy the Web application to the server. Scroll down the page until you find the box WAR file to deploy and then select the downloaded WAR file. Finally click the button Deploy. It may be necessary to restart Tomcat before running the application.

That's it! Access http://localhost:8080/samucs-web to begin the new DICOM visualization experience. The default username and password is samucs/samucs. I appreciate your feedback.

Screenshots:






Enjoy :)

Kindly regards,

Samuel.

Tuesday, March 17, 2009

Listing DICOM Header information with dcm4che 2

Hi All,

Some readers have asked me questions regarding how to access DICOM header information by DICOM Tag parameters. On this post I present you a quick tutorial on how to list all header information, including the Tag value, VR (value representation), Tag description, and the values of each field using the great dcm4che 2 toolkit.

(0008,0005) [CS] Specific Character Set [ISO_IR 100]
(0008,0008) [CS] Image Type [ORIGINAL]
(0008,0016) [UI] SOP Class UID [1.2.840.10008.5.1.4.1.1.2]
(0008,0020) [DA] Study Date [20040827]
(0008,0021) [DA] Series Date [20040827]
(0008,0022) [DA] Acquisition Date [20040827]
(0008,0023) [DA] Content Date [20040827]
(0008,0030) [TM] Study Time [100357.953000]
(0008,0031) [TM] Series Time [100607.062000]
(0008,0032) [TM] Acquisition Time [100622.688476]
(0008,0033) [TM] Content Time [100622.688476]
(0008,0050) [SH] Accession Number [null]
(0008,0060) [CS] Modality [CT]
(0008,0070) [LO] Manufacturer [SIEMENS]

Like the previous posts, we start coding a simple class with the default constructor. Let's name it ListDicomHeader.


public class ListDicomHeader {

public ListDicomHeader() {
// TODO Auto-generated method stub
}

public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

The next step is to code the method responsible for extracting the header info. Note that this method is recursive. This is done because some DICOM files bring encoded Items that may hold other DICOM objects denoted by de value representation SQ. So, we are handling also sequence information with this code. The method is written as follows:


public void listHeader(DicomObject object) {
Iterator iter = object.datasetIterator();
while(iter.hasNext()) {
DicomElement element = iter.next();
int tag = element.tag();
try {
String tagName = object.nameOf(tag);
String tagAddr = TagUtils.toString(tag);
String tagVR = object.vrOf(tag).toString();
if (tagVR.equals("SQ")) {
if (element.hasItems()) {
System.out.println(tagAddr +" ["+ tagVR +"] "+ tagName);
listHeader(element.getDicomObject());
continue;
}
}
String tagValue = object.getString(tag);
System.out.println(tagAddr +" ["+ tagVR +"] "+ tagName +" ["+ tagValue+"]");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Looking at the code, first we get an iterator to go through our DICOM dataset. Then we code a while loop to get each DICOM element present in the header. At each iteration a new DicomElement is kept so we can access its values. The tag variable holds the current Tag value. From then on there are some useful functions that may help us a lot. We can use the nameOf method from DicomObject class to get the Tag description as a String. I also suggest you to have a look at the TagUtils class for other great functions. The vrOf function will return the value representation to the current element.

Then comes the recursive part. We test the VR to see if it's a sequence (SQ), if so then we check if this element has any Items. Then if the answer is true we get the new object and call the listHeader function again, starting the recursive loop. Each iteration then prints out the desired information.

Finally, to test this program we must a main method for this class. The method may be written as follows:


public static void main(String[] args) {
DicomObject object = null;
try {
DicomInputStream dis = new DicomInputStream(new File("c:/image.dcm"));
object = dis.readDicomObject();
dis.close();
} catch (Exception e) {
System.out.println(e.getMessage());
System.exit(0);
}
ListDicomHeader list = new ListDicomHeader();
list.listHeader(object);
}


That's it! Now we have a lot of information from our DICOM file header! Enjoy :)

Best regards,

Samuel.

Tuesday, December 9, 2008

Converting JPEG to DICOM using dcm4che 2

Hi Folks!

At last my small quiz has finished. It was just a few votes (15), however, we’ve got an interesting choice: the Jpeg to Dicom tutorial. So let’s see how we can encapsulate a Jpeg image into a Dicom dataset. This tutorial is based on jpg2dcm utility from dcm4che2 toolkit and you are supposed to know basic java programming, the Eclipse environment, and some Dicom stuff.

Open your Eclipse IDE and choose File > New > Java Project. Name it myJpegToDicom. Next we have to create a new class, so right-click the src package and select New > Class. Enter JpegToDicom for class name and select the main method option. You'll get something like this:


public class JpegToDicom {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

I strongly recommend that you have a look at my previous posts for reviewing some configuration steps. Inside the main’s body let’s code the following lines:


File jpgSource = new File("c:/picture.jpg");
File dcmDestination = new File("c:/picture.dcm");

The first line creates a new file which is our Jpeg image, and the second one creates our future Dicom file which will keep Jpeg data within. Then, we have to extract some header information from our Jpeg file. To make it easy to understand I decided to use other means than search for Jpeg header markers and hexadecimal numbers. So, let’s do the following:


try {
BufferedImage jpegImage = ImageIO.read(jpgSource);
if (jpegImage == null)
throw new Exception("Invalid file.");

We open a try block and then read our Jpeg into a BufferedImage through ImageIO.read() method. If this results in an invalid image so we may throw a new exception. Else, we’ve got a valid image and therefore valuable information about it. The BufferedImage class has a lot of useful methods for retrieving image data, then let’s save the number of color components (samples per pixel) of our image, the bits per pixel and the bits allocated:


int colorComponents = jpegImage.getColorModel().getNumColorComponents();
int bitsPerPixel = jpegImage.getColorModel().getPixelSize();
int bitsAllocated = (bitsPerPixel / colorComponents);
int samplesPerPixel = colorComponents;

It’s time to start building our Dicom dataset:


DicomObject dicom = new BasicDicomObject();
dicom.putString(Tag.SpecificCharacterSet, VR.CS, "ISO_IR 100");
dicom.putString(Tag.PhotometricInterpretation, VR.CS, samplesPerPixel == 3 ? "YBR_FULL_422" : "MONOCHROME2");

The first line creates a new basic Dicom object defined by dcm4che2 toolkit. The next one puts header information for Specific Character Set: ISO_IR 100 – it’s the same for ISO-8859-1 – the code for Latin alphabet. Finally, the last line puts header information for photometric interpretation (read with or without colors). So if our image has samples per pixel equals to 3, it has colors (YBR_FULL_422), else it’s a grayscale image (MONOCHROME2).

The following lines add integer values to our Dicom header. Note that all of them comes from BufferedImage methods. These values are mandatory when encapsulating. For more information you can check Part 3.5 of Dicom Standard.

dicom.putInt(Tag.SamplesPerPixel, VR.US, samplesPerPixel);
dicom.putInt(Tag.Rows, VR.US, jpegImage.getHeight());
dicom.putInt(Tag.Columns, VR.US, jpegImage.getWidth());
dicom.putInt(Tag.BitsAllocated, VR.US, bitsAllocated);
dicom.putInt(Tag.BitsStored, VR.US, bitsAllocated);
dicom.putInt(Tag.HighBit, VR.US, bitsAllocated-1);
dicom.putInt(Tag.PixelRepresentation, VR.US, 0);

Also, our Dicom header needs information about date and time of creation:

dicom.putDate(Tag.InstanceCreationDate, VR.DA, new Date());
dicom.putDate(Tag.InstanceCreationTime, VR.TM, new Date());

Every Dicom file has a unique identifier. Here we’re generating study, series and Sop instances UIDs. You may want to modify these values, but you should to care about their uniqueness.

dicom.putString(Tag.StudyInstanceUID, VR.UI, UIDUtils.createUID());
dicom.putString(Tag.SeriesInstanceUID, VR.UI, UIDUtils.createUID());
dicom.putString(Tag.SOPInstanceUID, VR.UI, UIDUtils.createUID());

Our Dicom header is almost done. The following command initiates Dicom metafile information considering JPEGBaseline1 as transfer syntax. This means this file has Jpeg data encapsulated instead common medical image pixel data. The most common Jpeg files use a subset of the Jpeg standard called baseline Jpeg. A baseline Jpeg file contains a single image compressed with the baseline discrete cosine transformation (DCT) and Huffman encoding.

dicom.initFileMetaInformation(UID.JPEGBaseline1);

After initiate the header we can open an output stream for saving our Dicom dataset as follows:

FileOutputStream fos = new FileOutputStream(dcmDestination);
BufferedOutputStream bos = new BufferedOutputStream(fos);
DicomOutputStream dos = new DicomOutputStream(bos);
dos.writeDicomFile(dicom);

The next three lines are the most important ones. According to Dicom Standard the data element PixelData (7FE0,0010), if encapsulated, has the value representation OB (Other Byte String) and its length shall be set to an undefined value (in this case -1). It also contains the encoded pixel data stream fragmented into one or more item(s):

dos.writeHeader(Tag.PixelData, VR.OB, -1);

The Item Tag (FFFE,E000) is followed by a 4 byte item length field encoding the explicit number of bytes of the item. The first item in the sequence of items before the encoded pixel data stream shall be a basic item with length equals to zero:

dos.writeHeader(Tag.Item, null, 0);

The next Item then keeps the length of our Jpeg file.

/*
According to Gunter from dcm4che team we have to take care that
the pixel data fragment length containing the JPEG stream has
an even length.
*/
int jpgLen = (int) jpgSource.length();
dos.writeHeader(Tag.Item, null, (jpgLen+1)&~1);

Now all we have to do is to fill this item with bytes taken from our Jpeg file:

FileInputStream fis = new FileInputStream(jpgSource);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);

byte[] buffer = new byte[65536];
int b;
while ((b = dis.read(buffer)) > 0) {
dos.write(buffer, 0, b);
}

Finally, the Dicom Standard tells that we have to put a last Tag: a Sequence Delimiter Item (FFFE,E0DD) with length equals to zero.

/*
According to Gunter from dcm4che team we have to take care that
the pixel data fragment length containing the JPEG stream has
an even length. So if needed the line below pads JPEG stream with
odd length with 0 byte.
*/
if ((jpgLen&1) != 0) dos.write(0);
dos.writeHeader(Tag.SequenceDelimitationItem, null, 0);
dos.close();
} catch(Exception e) {
System.out.println("ERROR: "+ e.getMessage());
}

That’s it! Now we have a Dicom file with Jpeg data encapsulated. The print screen below was taken from Sante Free Dicom Viwer and shows a Windows Vista sample Jpeg picture encapsulated into a Dicom file.



References:

Dicom Standard Part 3.5 - Annex A (Normative) Transfer Syntax Specifications - A4 Transfer Syntaxes for Encapsulation of Encoded Pixel Data.

Jpeg Huffman Coding Tutorial

I hope it helps!

Regards,

Samuel.

Monday, September 29, 2008

Processing DICOM Images using dcm4che 2

Hi All,

First of all I want to thank all of you visitors! This post shows how we can use dcm4che2 toolkit for performing image processing. Most of articles and tutorials on the web present only pixel data accessing and manipulation, but not Dicom to Dicom image processing. Here we will manipulate an original Dicom image and then save it as a new Dicom processed image. You're supposed to know basic Java programming, the Eclipse environment and some Dicom stuff.


Lets start. Open your Eclipse IDE and choose File > New > Java Project. Name it myDicomImageProcessing. The next step is to create a new class, so right-click the src package and select New > Class. Enter DicomImageProcessing for class name and select the main method option. You'll get something like this:

public class DicomImageProcessing {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

I encourage you to have a look at my last post Converting DICOM to JPEG because there are some repeated code here which there is no need to be explained again. Inside the main's body let's code the following line:

File sourceFile = new File("c:/original.dcm");

This will be our original Dicom file. Next we will open this file and get its pixel data:

try {
Iterator iter = ImageIO.getImageReadersByFormatName("DICOM");
ImageReader reader = (ImageReader) iter.next();
DicomImageReadParam param = (DicomImageReadParam) reader.getDefaultReadParam();
ImageInputStream iis = ImageIO.createImageInputStream(sourceFile);

reader.setInput(iis, false);
Raster raster = reader.readRaster(0, param);

Our ImageReader is able to return a complete Raster from our Dicom image. According to Java documentation a Raster represents values for pixels occupying a particular rectangular area (read pixel array). Then, if our raster object is null we got some errors opening the file, so we may display an error message:

if (raster == null) {
System.out.println("Error: couldn't read Dicom image!");
return;
}
iis.close();

Ok, we read the file and our raster object holds all pixel data information. Now comes the image processing tour. For this example I chose Java ConvolveOp class for performing blurring, embossing and sharpening operations. It implements a convolution from the source to the destination.

Convolution using a convolution kernel is a spatial operation that computes the output pixel from an input pixel by multiplying the kernel with the surround of the input pixel. This allows the output pixel to be affected by the immediate neighborhood in a way that can be mathematically specified with a kernel.

Great, we also need to use the Kernel class. This class defines a matrix that describes how a specified pixel and its surrounding pixels affect the value computed for the pixel's position in the output image of a filtering operation.

Now let's create a new kernel for applying an emboss filter to our Dicom image:

float[] emboss = new float[] { -2,0,0, 0,1,0, 0,0,2 };
Kernel kernel = new Kernel(3, 3, emboss);

See that our kernel is a simple matrix. You can change this values further and check the results, you are the man :) Next let's apply the filter through our ConvolveOp class.

ConvolveOp op = new ConvolveOp(kernel);
Raster newRaster = op.filter(raster, null);

Note that, we just pass our kernel as a parameter and create a new ConvolveOp object. The filter(src,dst) method can return a BufferedImage or a new Raster object containing all the manipulated pixel data. So we have to choose the second option. See that we set null to the raster destination parameter, this force the creation of a new Raster as a result. That's it! Our Dicom image was processed!

In order to save a new Dicom file that contains our processed image, we have to do the following:
1) Extract the array element from the raster DataBuffer;
2) Create a Dicom object without pixel data;
3) Add to the Dicom object the pixel data extracted from the DataBuffer;
4) Write the modified Dicom object to a file;

So let's go! In this example I use an 16Bit MR Dicom image and its raster holds a DataBufferUShort object, so we have 16Bit pixels stored on short type arrays. Depending on the file you may get a DataBufferByte object inside the raster and you'll have to adapt my example code. To extract the array just code the following lines:

DataBufferUShort buffer = (DataBufferUShort) newRaster.getDataBuffer();
short[] pixelData = buffer.getData();

The next step is to create a copy of our Dicom file without pixel data. This can be done by calling the getDicomObject() method from the DicomStreamMetaData class.

DicomStreamMetaData dsmd = (DicomStreamMetaData) reader.getStreamMetadata();
DicomObject dicom = dsmd.getDicomObject();

Allright, we got the Dicom object! All we have to do so is to add our modified pixel data inside this object. We need to access the PixelData tag and insert our pixelData short array like the code below:

dicom.putShorts(Tag.PixelData, dicom.vrOf(Tag.PixelData), pixelData);

Finally, lets save our new Dicom file containing the processed image:

File f = new File("C:/processed.dcm");
FileOutputStream fos = new FileOutputStream(f);
BufferedOutputStream bos = new BufferedOutputStream(fos);
DicomOutputStream dos = new DicomOutputStream(bos);
dos.writeDicomFile(dicom);
dos.close();

And, if we get any errors let's display a simple message:

} catch(Exception e) {
System.out.println("Error: couldn't read dicom image! "+ e.getMessage());
return;
}
}

It should work! I successfully opened the processed.dcm file on ImageJ. In addition, you may want to test other processing kernels and save different sets of processed images. You can try the following:

float[] blurring = new float[] { 1f/9f,1f/9f,1f/9f, 1f/9f,1f/9f,1f/9f, 1f/9f,1f/9f,1f/9f };
float[] sharpening = new float[] { -1,-1,-1, -1,9,-1, -1,-1,-1 };

If you have any problems running my examples just let me know!

Best regards,

Samuel.

Tuesday, March 25, 2008

Converting DICOM to JPEG using dcm4che 2

Hi Folks,

Sorry, I was quite busy these days, weeks, months :) Now, I can share with you how to convert any Dicom image to Jpeg using the amazing dcm4che 2.0 toolkit. I've spent a lot of time trying to figure out the magic of dcm4che and I've got some stuff that will be posted later.However, the best way to learn dcm4che is studying its utilities apps, so dcm2jpg is the one you must have a look. From now on let's just see how to perform the conversion.

First, you have to download the latest version of dcm4che libraries. Also, you'll need the JAI ImageIO Toolkit in order to quickly read pixel data from Dicom images. And if you don't have any java editor get the best one: Eclipse. You are supposed to know basic java programming, the Eclipse environment and some Dicom stuff.

Lets start. Open your Eclipse IDE and choose File > New > Java Project. Name it myDicomToJpeg. The next step is to create a new class, so right-click the src package and select New > Class. Enter DicomToJpeg for class name and select the main method option. You'll get something like this:

public class DicomToJpeg {
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}

In order to use dcm4che classes we have to configure the project's build path. Right-click the project's main folder and select Properties. Select the Java Build Path option. Under Libraries tab we'll find the Add External Jars button. Click on it to select all dcm4che jar files and all JAI ImageIO jar files. Now our project is able to work with dcm4che.

Write the following line inside the main's body. This is our Dicom file:

File myDicomFile = new File("c:/dicomImage.dcm");

Then let's declare what will be our Jpeg image:

BufferedImage myJpegImage = null;

The following line returns an Iterator containing all currently registered ImageReaders that claim to be able to decode the named format (e.g., "DICOM", "jpeg", "tiff").

Iterator<ImageReader> iter = ImageIO.getImageReadersByFormatName("DICOM");

The java documentation says an ImageReader object are normally instantiated by the service provider interface (SPI) class for the specific format. Service provider classes (e.g., instances of ImageReaderSpi) are registered with the IIORegistry, which uses them for format recognition and presentation of available format readers and writers. So let's get our ImageReader object.

ImageReader reader = (ImageReader) iter.next();

If you check carefully dcm4che libraries you'll find some specific imageio packages. That's where it keeps the secret of reading Dicom pixel data. Therefore, our ImageReader object is now an instance of a specific SPI class for the Dicom format.

In the following line we get parameters for reading the Dicom image. The java documentation says an ImageReadParam class describe how a stream is to be decoded. Instances of this class or its subclasses are used to supply prescriptive "how-to" information to instances of ImageReader.

DicomImageReadParam param = (DicomImageReadParam) reader.getDefaultReadParam();

Before read all pixel data we have to create an ImageInputStream object for use by our ImageReader object. Note that this input stream has our Dicom file as a parameter. As this process throws an IOException it must be between a try-catch block.

Now all we have to do is to call the read() method from our ImageReader object together with our prescriptive Dicom parameters. The result is a new BufferedImage filled with Dicom pixel data. Pretty easy, hun :)

try {
ImageInputStream iis = ImageIO.createImageInputStream(myDicomFile);
reader.setInput(iis, false);
myJpegImage = reader.read(0, param);
iis.close();

That's it! We read the Dicom image into our myJpegImage object. The following lines just test if we really succeeded. If not, we just print a message.

if (myJpegImage == null) {
System.out.println("\nError: couldn't read dicom image!");
return;
}

You may be asking: ok, how do I get my Jpeg file? The answer is in the following lines. We firstly need to create a Jpeg file that will be sent to an OutputStream to be saved. Then, the JPEGImageEncoder object is responsible for encoding our Jpeg image into this output. When we close the OutputStream our Jpeg file is saved. We're done!!

File myJpegFile = new File("c:/jpegImage.jpg");
OutputStream output = new BufferedOutputStream(new FileOutputStream(myJpegFile));
JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(output);
encoder.encode(myJpegImage);
output.close();

Finally, if our try to read the image failed, we probably got an exception. So let's handle it printing a message.

}
catch(IOException e) {
System.out.println("\nError: couldn't read dicom image!"+ e.getMessage());
return;
}

Have a nice day! Hope it helps :)

Samuel.

Wednesday, January 16, 2008

Setting Up dcm4chee for Oracle Database

Hi Folks!

I'm starting my masters degree this year and I wrote an interesting research project to build a complete medical image processing server which works together with dcm4chee: a DICOM clinical data manager system. In this post I will show you how to setup dcm4chee properly using the great and free Oracle Express Database. This tutorial is for Windows.

Firstly, download OracleXE and launch it. The installation is quite simple and intuitive. When asked create the system account that will manage the database, so type system for username and manager for password. Wait copying its files and then finish the wizard. On the Windows command prompt access the directory:

oraclexe\app\oracle\product\10.2.0\server\BIN

...and execute the sqlplus.exe program. You will be asked for entering an username and password, which is system and manager. If no problems occurred you are now connected to Oracle and will get the C:\SQL> command line.




The Oracle Express brings a clear web interface where you may perform the database management, however, it uses the Jetty server that works on HTTP port 8080. If you try to run any other server like JBoss you'll get stuck at errors because port 8080 wont't be available. To overcome this issue you must change the HTTP port for Oracle. On SqlPlus type the following SQL commands:

SQL> begin
2 dbms_xdb.sethttpport('18080');
3 end;
4 /

After execute these lines you'll change Oracle HTTP port from 8080 to 18080. We must do it because dcm4chee works under JBoss server that also uses port 8080 for web access. Meanwhile, we're done with Oracle!

Download dcm4chee binaries for Oracle and also get the amazing JBoss application server. I chose version 2.13.0 of dcm4chee and the JBoss 4.2.2.GA release. Extract dcm4chee files at the root directory "C:\". Avoid using a directory that has a name which contains spaces as installation directory. So make it simple, just rename the extracted folder
to dcm4chee.

The next step is to extract JBoss files to the root directory and then rename the new folder to jboss. When finished, you have to copy some files from JBoss to dcm4chee by executing install_jboss.bat with the path of your JBoss installation directory as parameter. Access the Windows command prompt to execute the script. Eg. C:\dcm4chee\bin>intall_jboss.bat C:\jboss.




That's it, dcm4chee is almost done! Come back to Oracle for creating your PACS database. Again, access the SqlPlus with your system account and execute the commands below. They create a new Oracle tablespace named pacsdb and a new database user pacs. Every dcm4chee data will be stored based on these configurations.

CREATE TABLESPACE pacsdb
DATAFILE 'C:\xxx\pacsdb.ORA' SIZE 5M
AUTOEXTEND ON NEXT 5120K
DEFAULT STORAGE (INITIAL 10K NEXT 50K MINEXTENTS 1 MAXEXTENTS 121 PCTINCREASE 10) ONLINE;

CREATE USER pacs IDENTIFIED BY pacs
DEFAULT TABLESPACE pacsdb TEMPORARY TABLESPACE TEMP
QUOTA UNLIMITED ON pacsdb;

GRANT DBA TO pacs WITH ADMIN OPTION;

Reopen the Windows command prompt and execute SqlPlus. Now you have to establish connection with Oracle through your new user pacs and password pacs for generating all tables, primary keys, indexes, and so on. Therefore, type the following command and wait:

SQL> @C:\dcm4chee\sql\create.ora;

If no errors occurred your dcm4chee database is complete!

Important Notes:

1) dcm4chee doesn't contain an appropriate Jdbc driver for Oracle, so you need to download this driver and copy it to dcm4chee\server\default\lib\.

2)Use OCI connection for OracleXE. Change de Jdbc url connection in dcm4chee\server\default\deploy\pacs-oracle-ds.xml. Locate the tag <connection-url> and change its content to jdbc:oracle:oci:@xe.

3) Search Oracle installation directory for ocijdbc10g.dll and copy this file to dcm4chee\bin\native\.

Mission accomplished! Open the Windows command prompt, access dcm4chee\bin directory and execute run.bat to startup JBoss server. Finally, open your preffered web browser and go to localhost:8080/dcm4chee-web to see dcm4chee in action!




If you have any problems with this tutorial just let me know.
See you on the next post :)

Wednesday, November 28, 2007

Get rid of YouTube Downloaders! Firebug it!

Hi everyone,

If you are trying to download videos and always get stuck at YouTube downloader programs, don't worry, just Firebug it!

The amazing browser Mozilla Firefox is not a simple browser, but a rich and helpful tool for web developers and programmers. Among its extensions we can find one that may upset some world wide portals, I present you Firebug. Firebug "integrates with Firefox to put a wealth of web development tools at your fingertips while you browse. You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page".

These days I was trying to download videos from YouTube using some programs that claim to do that easily. However, I got stuck all the time! The programs really didn't work at all. So I decide to have a look at YouTube site through Firebug tool under Mozilla Firefox. There was the key! YouTube videos are "hidden" on different servers and URLs. It's speculation but I believe this is why downloader programs can't do the trick, they are not able to reach those servers and URLs. Using Firebug I could download my favourite videos properly.

First you have to download and install Mozilla Firefox. When finished, install Firebug on Firefox. Then restart the browser and be sure you have this icon at the browser bottom right corner:



To start working with Firebug and YouTube videos you need to access the YouTube site first. Then, just click on Firebug's green icon to open its tool panel. Now you have something like this:



Inside Firebug's panel you can debug Javascripts, inspect Html tags, explore the Html DOM tree, watch the XmlHttpRequest asynchronous requests and even know how long does every object on the page take to be downloaded by the browser. It's really amazing! Now as you were introduced to Firebug, let's see how to download your favourite YouTube videos.

Search for your video at YouTube.com and then click on it to start watching. Be sure that is this video you want to download. Now comes Firebug magic! Click on its green icon to open the tool panel. There is a tab named "Net", select it. This tab shows every object on the page and its respective download time. Now just hit Ctrl+F5 to refresh the page and see each object being downloaded by the browser.



Look at the red arrow (it's my arrow). There it is, your favourite video waiting for you to be downloaded. Can you see the real video URL? No more words, let's download the video. Right click the line where you see "get_video" followed by a weird URL and then hit "Open in new tab". Wow, Firefox want me to save a FLV (Flash Video) file? Yes, just do it.



Wait until the download is finished. The last step is rename the downloaded file from "get_video" to "youfilename.flv".

That's all folks!

Enjoy!

Wednesday, October 3, 2007

A Game Engine Project

Hi Folks!

From the last three years I've been working hard on a project I called MyGameEngine. The goal was to build a simple game engine where programmers may create their own virtual worlds, or their own 3D games!

On this post I bring you this great project. It's entirely written in C++ code and the whole graphical stuff was developed through the OpenGL API. If you're interested in downloading the project source code just let me know: samucs@gmail.com. Meanwhile this blog doesn't support downloads.

Below I present a screenshot of MyGameEngine in action!
Enjoy!


Welcome

Welcome to my blog! I'm Samuel and here you'll find a lot of stuff related to computer science, programming, research and development, and some unknown mysteries. Feel free to post any comment! Enjoy!