private List<String> getPatientIds(DataMatrix dataMatrix) {
    List<LinkedList<String>> patientIds = dataMatrix.getColumnData(PATIENT_ID);
    if (patientIds.isEmpty()) {
      patientIds = dataMatrix.getColumnData(FOLLOW_UP_PATIENT_ID);
    }

    return (patientIds.isEmpty())
        ? Collections.<String>emptyList()
        : convertFollowupPatientIds(patientIds.get(0));
  }
  // ----------------------------------------------------------------------------------------
  public void createAndBroadcastMatrix(
      String[] rowNames, String[] columnNames, double[] data, String matrixName) {
    // System.out.println (" ------- RShellGoose.cabm");
    // System.out.println ("   row name count: " + rowNames.length);
    // System.out.println ("   col name count: " + columnNames.length);
    // System.out.println ("      data length: " + data.length);
    // System.out.println ("             name: " + matrixName);
    DataMatrix matrix = new DataMatrix();

    int rowCount = rowNames.length;
    int columnCount = columnNames.length;
    matrix.setSize(rowCount, columnCount);
    if (matrixName != null) {
      matrix.setShortName(matrixName); //
      matrix.setName(matrixName);
    }

    matrix.setRowTitles(rowNames);
    matrix.setColumnTitles(columnNames);

    for (int r = 0; r < rowCount; r++) {
      double[] rowValues = new double[columnCount];
      int fromPosition = r * columnCount;
      System.arraycopy(data, fromPosition, rowValues, 0, columnCount);
      matrix.set(r, rowValues);
    } // for r

    broadcastMatrix(matrix);
  } // createAndBroadcastMatrix
 // ----------------------------------------------------------------------------------------
 public void handleMatrix(String source, DataMatrix matrix) {
   this.matrix = matrix;
   System.out.println(
       "matrix ready, dimension "
           + this.matrix.getRowCount()
           + " x "
           + this.matrix.getColumnCount());
   defaultSpecies = matrix.getSpecies();
 }
  private String getValue(int index, String columnName, DataMatrix dataMatrix) {
    List<LinkedList<String>> columnData = dataMatrix.getColumnData(columnName);

    String value = MissingAttributeValues.getNotAvailable();
    if (!columnData.isEmpty()) {
      value = columnData.get(0).get(index);
    }
    return (value.isEmpty()) ? MissingAttributeValues.getNotAvailable() : value;
  }
  // ----------------------------------------------------------------------------------------
  public double[] getAllMatrixData() {
    if (matrix == null) {
      System.out.println("The R goose has not received a matrix broadcast.");
      return new double[0];
    }

    int rowCount = matrix.getRowCount();
    int columnCount = matrix.getColumnCount();
    int total = rowCount * columnCount;
    double result[] = new double[total];

    for (int r = 0; r < rowCount; r++) {
      double[] rowValues = matrix.get(r);
      int toPosition = r * columnCount;
      System.arraycopy(rowValues, 0, result, toPosition, columnCount);
    } // for r

    return result;
  } // getAllMatrixData
 // ----------------------------------------------------------------------------------------
 void broadcastMatrix(DataMatrix matrix) {
   try {
     matrix.setSpecies(defaultSpecies);
     // matrix.setName();
     gaggleBoss.broadcastMatrix(myGaggleName, targetGoose, matrix);
   } catch (RemoteException rex) {
     System.err.println(
         "error rmi selecting at boss, from RShellGoose.broadcastMatrix() " + myGaggleName);
   }
 } // broadcastMatrix
 // ----------------------------------------------------------------------------------------
 public double[] getMatrixRow(int rowNumber) {
   if (matrix == null) return new double[0];
   else return matrix.get(rowNumber);
 }
 // ----------------------------------------------------------------------------------------
 public String[] getMatrixColumnNames() {
   if (matrix == null) return new String[0];
   else return matrix.getColumnTitles();
 }
 // ----------------------------------------------------------------------------------------
 public String[] getMatrixRowNames() {
   if (matrix == null) return new String[0];
   else return matrix.getRowTitles();
 }
 // ----------------------------------------------------------------------------------------
 public int getMatrixColumnCount() {
   if (matrix == null) return 0;
   else return matrix.getColumnCount();
 }
 // ----------------------------------------------------------------------------------------
 public int getMatrixRowCount() {
   if (matrix == null) return 0;
   else return matrix.getRowCount();
 }