changeset 1115:462976c57bda

Added ability to convert gyrocom images to dicom images.
author neelin <neelin>
date Fri, 12 Sep 1997 23:13:28 +0000
parents dbe805bf6aa4
children 4b38dea085eb
files conversion/gcomserver/Makefile conversion/gcomserver/gcom_prototypes.h conversion/gcomserver/gcomserver-debug.c conversion/gcomserver/gcomserver.c conversion/gcomserver/gcomserver.h conversion/gcomserver/project_file.c conversion/gcomserver/reply.c conversion/gcomserver/spi_element_defs.h
diffstat 8 files changed, 126 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- a/conversion/gcomserver/Makefile
+++ b/conversion/gcomserver/Makefile
@@ -12,7 +12,7 @@
 EXTRA_OBJS = spi_element_defs.o open_connection.o reply.o spi_message.o \
              save_transferred_object.o use_the_files.o \
              gyro_to_minc.o gyro_read.o minc_file.o \
-             string_to_filename.o project_file.o
+             string_to_filename.o project_file.o convert_to_dicom.o
 HEADERS  = gcomserver.h gcom_prototypes.h spi_element_defs.h gyro_to_minc.h
 OPT      = -O
 CDEFINES = -DDEBUG#                        cpp defines
--- a/conversion/gcomserver/gcom_prototypes.h
+++ b/conversion/gcomserver/gcom_prototypes.h
@@ -4,7 +4,8 @@
 public void open_connection(int argc, char *argv[], 
                             Acr_File **afpin, Acr_File **afpout);
 public Acr_Message gcbegin_reply(Acr_Message input_message, int *num_files,
-                                 char **project_name);
+                                 char **project_name, 
+                                 Project_File_Info *project_info);
 public Acr_Message ready_reply(Acr_Message input_message);
 public Acr_Message send_reply(Acr_Message input_message);
 public Acr_Message gcend_reply(Acr_Message input_message);
@@ -66,3 +67,4 @@
                              Project_File_Info *project_info);
 public void get_project_option_string(char *project_option_string,
                                       int maxlen_project_option);
+public void convert_to_dicom(Acr_Group group_list);
--- a/conversion/gcomserver/gcomserver-debug.c
+++ b/conversion/gcomserver/gcomserver-debug.c
@@ -1,5 +1,7 @@
 #define DO_INPUT_TRACING
 #define KEEP_FILES
 #define DO_HIGH_LOGGING
+#undef DO_HIGH_LOGGING
+#undef DO_INPUT_TRACING
+#undef KEEP_FILES
 #include "gcomserver.c"
-#undef DO_HIGH_LOGGING
--- a/conversion/gcomserver/gcomserver.c
+++ b/conversion/gcomserver/gcomserver.c
@@ -4,9 +4,12 @@
 @GLOBALS    : 
 @CREATED    : November 22, 1993 (Peter Neelin)
 @MODIFIED   : $Log: gcomserver.c,v $
-@MODIFIED   : Revision 6.0  1997-09-12 13:23:50  neelin
-@MODIFIED   : Release of minc version 0.6
+@MODIFIED   : Revision 6.1  1997-09-12 23:13:28  neelin
+@MODIFIED   : Added ability to convert gyrocom images to dicom images.
 @MODIFIED   :
+ * Revision 6.0  1997/09/12  13:23:50  neelin
+ * Release of minc version 0.6
+ *
  * Revision 5.0  1997/08/21  13:24:50  neelin
  * Release of minc version 0.5
  *
@@ -102,7 +105,7 @@
 ---------------------------------------------------------------------------- */
 
 #ifndef lint
-static char rcsid[]="$Header: /private-cvsroot/minc/conversion/gcomserver/gcomserver.c,v 6.0 1997-09-12 13:23:50 neelin Rel $";
+static char rcsid[]="$Header: /private-cvsroot/minc/conversion/gcomserver/gcomserver.c,v 6.1 1997-09-12 23:13:28 neelin Exp $";
 #endif
 
 #include <sys/types.h>
@@ -161,6 +164,7 @@
    char last_file_name[256];
    char *project_name = NULL;
    char logfilename[256];
+   Project_File_Info project_info;
 
    /* Create minc history string */
    {
@@ -255,21 +259,24 @@
                break;
             }
             output_message = gcbegin_reply(input_message, &num_files,
-                                           &project_name);
+                                           &project_name, &project_info);
             if (project_name == NULL) {
                num_files = 0;
                break;
             }
+
             file_list = MALLOC((size_t) num_files * sizeof(*file_list));
             for (cur_file=0; cur_file < num_files; cur_file++) {
                file_list[cur_file] = NULL;
             }
             file_info_list = MALLOC(num_files * sizeof(*file_info_list));
             cur_file = -1;
-            state = WAITING_FOR_OBJECT;
             if (Do_logging >= LOW_LOGGING) {
                (void) fprintf(stderr, "\nCopying a group of files:\n");
             }
+
+            /* Change to next state */
+            state = WAITING_FOR_OBJECT;
             break;
 
             /* Ready */
@@ -308,22 +315,31 @@
                state = DISCONNECTING;
                break;
             }
+
             /* Create the output message */
             output_message = gcend_reply(input_message);
             /* Print message */
             if (Do_logging >= LOW_LOGGING) {
                (void) fprintf(stderr, "\nFinished group copy.\n");
             }
+
             /* Do something with the files */
+            if (project_info.type == PROJECT_DIRECTORY) {
 #ifdef DO_INPUT_TRACING
-            /* Disable input tracing */
-            acr_file_disable_trace(afpin);
+               /* Disable input tracing */
+               acr_file_disable_trace(afpin);
 #endif
-            use_the_files(project_name, num_files, file_list, file_info_list);
+               use_the_files(project_name, num_files, file_list, file_info_list);
 #ifdef DO_INPUT_TRACING
-   /* Enable input tracing */
-            acr_file_enable_trace(afpin);
+               /* Enable input tracing */
+               acr_file_enable_trace(afpin);
 #endif
+            }
+            else if (project_info.type == PROJECT_DICOM) {
+               acr_close_dicom_connection(project_info.info.dicom.afpin,
+                                          project_info.info.dicom.afpout);
+            }
+
             /* Remove the temporary files */
             cleanup_files(num_files, file_list);
             free_list(num_files, file_list, file_info_list);
@@ -388,12 +404,38 @@
             state = TERMINATING;
             break;
          }
-         save_transferred_object(group_list, 
-                                 file_prefix, &file_list[cur_file],
-                                 &file_info_list[cur_file]);
-         if (Do_logging >= LOW_LOGGING) {
-            (void) fprintf(stderr, "   Copied %s\n", file_list[cur_file]);
+
+         /* Do something with the data */
+         if (project_info.type == PROJECT_DIRECTORY) {
+            save_transferred_object(group_list, 
+                                    file_prefix, &file_list[cur_file],
+                                    &file_info_list[cur_file]);
+            if (Do_logging >= LOW_LOGGING) {
+               (void) fprintf(stderr, "   Copied %s\n", file_list[cur_file]);
+            }
          }
+         else if (project_info.type == PROJECT_DICOM) {
+
+            /* Check that we have image data and send it */
+            if (acr_find_group_element(group_list, ACR_Pixel_data)
+                != NULL) {
+               convert_to_dicom(group_list);
+               if (!acr_send_group_list(project_info.info.dicom.afpin,
+                                        project_info.info.dicom.afpout, 
+                                        group_list,
+                                        ACR_MR_IMAGE_STORAGE_UID)) {
+                  (void) fprintf(stderr, "Error sending dicom image\n");
+                  state = TERMINATING;
+                  break;
+               }
+               if (Do_logging >= LOW_LOGGING) {
+                  (void) fprintf(stderr, ".");
+                  (void) fflush(stderr);
+               }
+            }
+         }
+
+         /* Delete the input data */
          acr_delete_group_list(group_list);
       }
 
--- a/conversion/gcomserver/gcomserver.h
+++ b/conversion/gcomserver/gcomserver.h
@@ -5,9 +5,12 @@
 @GLOBALS    : 
 @CREATED    : November 23, 1993 (Peter Neelin)
 @MODIFIED   : $Log: gcomserver.h,v $
-@MODIFIED   : Revision 6.0  1997-09-12 13:23:50  neelin
-@MODIFIED   : Release of minc version 0.6
+@MODIFIED   : Revision 6.1  1997-09-12 23:13:28  neelin
+@MODIFIED   : Added ability to convert gyrocom images to dicom images.
 @MODIFIED   :
+ * Revision 6.0  1997/09/12  13:23:50  neelin
+ * Release of minc version 0.6
+ *
  * Revision 5.1  1997/09/11  13:09:40  neelin
  * Added more complicated syntax for project files so that different things
  * can be done to the data. The old syntax is still supported.
@@ -159,6 +162,8 @@
          char hostname[SHORT_LINE];
          char port[SHORT_LINE];
          char AEtitle[SHORT_LINE];
+         Acr_File *afpin;
+         Acr_File *afpout;
       } dicom;
 
    } info;
--- a/conversion/gcomserver/project_file.c
+++ b/conversion/gcomserver/project_file.c
@@ -7,9 +7,12 @@
 @CALLS      : 
 @CREATED    : February 14, 1995 (Peter Neelin)
 @MODIFIED   : $Log: project_file.c,v $
-@MODIFIED   : Revision 6.0  1997-09-12 13:23:50  neelin
-@MODIFIED   : Release of minc version 0.6
+@MODIFIED   : Revision 6.1  1997-09-12 23:13:28  neelin
+@MODIFIED   : Added ability to convert gyrocom images to dicom images.
 @MODIFIED   :
+ * Revision 6.0  1997/09/12  13:23:50  neelin
+ * Release of minc version 0.6
+ *
  * Revision 5.1  1997/09/11  13:09:40  neelin
  * Added more complicated syntax for project files so that different things
  * can be done to the data. The old syntax is still supported.
@@ -212,6 +215,8 @@
                   project_info->info.dicom.hostname[0] = '\0';
                   project_info->info.dicom.port[0] = '\0';
                   project_info->info.dicom.AEtitle[0] = '\0';
+                  project_info->info.dicom.afpin = NULL;
+                  project_info->info.dicom.afpout = NULL;
                }
                else {
                   error = "Unknown project type";
--- a/conversion/gcomserver/reply.c
+++ b/conversion/gcomserver/reply.c
@@ -4,9 +4,12 @@
 @GLOBALS    : 
 @CREATED    : November 22, 1993 (Peter Neelin)
 @MODIFIED   : $Log: reply.c,v $
-@MODIFIED   : Revision 6.0  1997-09-12 13:23:50  neelin
-@MODIFIED   : Release of minc version 0.6
+@MODIFIED   : Revision 6.1  1997-09-12 23:13:28  neelin
+@MODIFIED   : Added ability to convert gyrocom images to dicom images.
 @MODIFIED   :
+ * Revision 6.0  1997/09/12  13:23:50  neelin
+ * Release of minc version 0.6
+ *
  * Revision 5.1  1997/09/11  13:09:40  neelin
  * Added more complicated syntax for project files so that different things
  * can be done to the data. The old syntax is still supported.
@@ -206,6 +209,7 @@
 @INPUT      : input_message
 @OUTPUT     : num_files - number of files needed
               project_name - name to use for project file
+              project_info
 @RETURNS    : output_message
 @DESCRIPTION: Responds to GCBEGINq message
 @METHOD     : 
@@ -215,11 +219,12 @@
 @MODIFIED   : 
 ---------------------------------------------------------------------------- */
 public Acr_Message gcbegin_reply(Acr_Message input_message, int *num_files,
-                                 char **project_name)
+                                 char **project_name, 
+                                 Project_File_Info *project_info)
 {
    Acr_Group group, group_list;
    Acr_Element element;
-   char project_option_string[512];
+   char operator_string[512];
    void *ptr;
    int index;
 
@@ -281,11 +286,42 @@
 
    /* Check that the project file is okay - if not get a string listing 
       possible project names and send it back */
-   if (read_project_file(*project_name, NULL)) {
+   operator_string[0] = '\0';
+   if (read_project_file(*project_name, project_info)) {
 
       /* Print an error message */
       (void) fprintf(stderr, "Unknown project \"%s\"\n", *project_name);
 
+      /* Set a message for the operator */
+      (void) sprintf(operator_string, 
+                     "Unknown volume, try remote DOR volume: ");
+      index = strlen(operator_string);
+      get_project_option_string(&operator_string[index],
+                                sizeof(operator_string) - index);
+
+   }
+
+   /* Check for a dicom-type project */
+   else if (project_info->type == PROJECT_DICOM) {
+
+      /* Make the dicom connection */
+      if (!acr_open_dicom_connection(project_info->info.dicom.hostname,
+                                     project_info->info.dicom.port,
+                                     project_info->info.dicom.AEtitle,
+                                     "GCOMTODICOM",
+                                     ACR_MR_IMAGE_STORAGE_UID,
+                                     ACR_IMPLICIT_VR_LITTLE_END_UID,
+                                     &project_info->info.dicom.afpin,
+                                     &project_info->info.dicom.afpout)) {
+         (void) sprintf(operator_string, "Unable to connect to host %s",
+                        project_info->info.dicom.hostname);
+      }
+
+   }
+
+   /* Handle any error */
+   if (operator_string[0] != '\0') {
+
       /* Set the project name to NULL as a signal to the caller */
       FREE(*project_name);
       *project_name = NULL;
@@ -303,22 +339,17 @@
       }
 
       /* Set a message for the operator */
-      (void) sprintf(project_option_string, 
-                     "Unknown volume, try remote DOR volume: ");
-      index = strlen(project_option_string);
-      get_project_option_string(&project_option_string[index],
-                                sizeof(project_option_string) - index);
-      index = strlen(project_option_string);
+      index = strlen(operator_string);
       if ((index % 2) != 0) {
-         project_option_string[index] = ' ';
-         project_option_string[index+1] = '\0';
+         operator_string[index] = ' ';
+         operator_string[index+1] = '\0';
       }
       element = acr_find_group_element(group_list, SPI_Operator_text);
       if (element != NULL) {
          ptr = acr_get_element_data(element);
          if (ptr != NULL) FREE(ptr);
-         acr_set_element_data(element, strlen(project_option_string),
-                              strdup(project_option_string));
+         acr_set_element_data(element, strlen(operator_string),
+                              strdup(operator_string));
       }
    }
 
--- a/conversion/gcomserver/spi_element_defs.h
+++ b/conversion/gcomserver/spi_element_defs.h
@@ -108,6 +108,7 @@
 GLOBAL_ELEMENT(ACR_Dataset_type              , 0x0000, 0x0800, US);
 GLOBAL_ELEMENT(ACR_Status                    , 0x0000, 0x0900, US);
 GLOBAL_ELEMENT(ACR_Affected_SOP_instance_UID , 0x0000, 0x1000, UI);
+
 GLOBAL_ELEMENT(ACR_Data_set_type             , 0x0008, 0x0040, US);
 GLOBAL_ELEMENT(ACR_Data_set_subtype          , 0x0008, 0x0041, LO);
 GLOBAL_ELEMENT(ACR_Patient_name              , 0x0010, 0x0010, PN);
@@ -115,7 +116,6 @@
 GLOBAL_ELEMENT(ACR_Acquisition               , 0x0020, 0x0012, IS);
 GLOBAL_ELEMENT(ACR_Image                     , 0x0020, 0x0013, IS);
 GLOBAL_ELEMENT(ACR_Image_location            , 0x0028, 0x0200, US);
-
 GLOBAL_ELEMENT(ACR_Study_date            , 0x0008, 0x0020, DA);
 GLOBAL_ELEMENT(ACR_Study_time            , 0x0008, 0x0030, TM);
 GLOBAL_ELEMENT(ACR_Modality              , 0x0008, 0x0060, CS);
@@ -148,6 +148,7 @@
 GLOBAL_ELEMENT(ACR_Bits_stored           , 0x0028, 0x0101, US);
 GLOBAL_ELEMENT(ACR_Smallest_pixel_value  , 0x0028, 0x0104, US);
 GLOBAL_ELEMENT(ACR_Largest_pixel_value   , 0x0028, 0x0105, US);
+GLOBAL_ELEMENT(ACR_Pixel_data            , 0x7fe0, 0x0010, OW);
 
 /* Element id's for SPI */
 GLOBAL_ELEMENT(SPI_Recognition_code, 0x0001, 0x0010, LO);