Monday, February 24, 2025

Performing Image Semantic Segmentation on CamVid Data Unsing DeepLabV3+ Model with MobileNetV2 Backbone in MATLAB Environment



outputFolder = "C:\Anwar\CamVid\"

imgDir = fullfile(outputFolder,'train\');

imds = imageDatastore(imgDir);



I = readimage(imds, 200);

I = histeq(I);

imshow(I)


function labelIDs = camvidPixelLabelIDs()

% Return the label IDs corresponding to each class.

%

% The CamVid dataset has 32 classes. Group them into 11 classes following

% the original SegNet training methodology [1].

%

% The 11 classes are:

%   "Sky" "Building", "Pole", "Road", "Pavement", "Tree", "SignSymbol",

%   "Fence", "Car", "Pedestrian",  and "Bicyclist".

%

% CamVid pixel label IDs are provided as RGB color values. Group them into

% 11 classes and return them as a cell array of M-by-3 matrices. The

% original CamVid class names are listed alongside each RGB value. Note

% that the Other/Void class are excluded below.

labelIDs = { ...

    

    % "Sky"

    [

    128 128 128; ... % "Sky"

    ]

    

    % "Building" 

    [

    000 128 064; ... % "Bridge"

    128 000 000; ... % "Building"

    064 192 000; ... % "Wall"

    064 000 064; ... % "Tunnel"

    192 000 128; ... % "Archway"

    ]

    

    % "Pole"

    [

    192 192 128; ... % "Column_Pole"

    000 000 064; ... % "TrafficCone"

    ]

    

    % Road

    [

    128 064 128; ... % "Road"

    128 000 192; ... % "LaneMkgsDriv"

    192 000 064; ... % "LaneMkgsNonDriv"

    ]

    

    % "Pavement"

    [

    000 000 192; ... % "Sidewalk" 

    064 192 128; ... % "ParkingBlock"

    128 128 192; ... % "RoadShoulder"

    ]

        

    % "Tree"

    [

    128 128 000; ... % "Tree"

    192 192 000; ... % "VegetationMisc"

    ]

    

    % "SignSymbol"

    [

    192 128 128; ... % "SignSymbol"

    128 128 064; ... % "Misc_Text"

    000 064 064; ... % "TrafficLight"

    ]

    

    % "Fence"

    [

    064 064 128; ... % "Fence"

    ]

    

    % "Car"

    [

    064 000 128; ... % "Car"

    064 128 192; ... % "SUVPickupTruck"

    192 128 192; ... % "Truck_Bus"

    192 064 128; ... % "Train"

    128 064 064; ... % "OtherMoving"

    ]

    

    % "Pedestrian"

    [

    064 064 000; ... % "Pedestrian"

    192 128 064; ... % "Child"

    064 000 192; ... % "CartLuggagePram"

    064 128 064; ... % "Animal"

    ]

    

    % "Bicyclist"

    [

    000 128 192; ... % "Bicyclist"

    192 000 192; ... % "MotorcycleScooter"

    ]

    

    };

end


function classes = getClassNames()

classes = [

    "Sky"

    "Building"

    "Pole"

    "Road"

    "Pavement"

    "Tree"

    "SignSymbol"

    "Fence"

    "Car"

    "Pedestrian"

    "Bicyclist"

    ];

end


function pixelLabelColorbar(cmap, classNames)

% Add a colorbar to the current axis. The colorbar is formatted

% to display the class names with the color.


colormap(gca,cmap)


% Add colorbar to current figure.

c = colorbar('peer', gca);


% Use class names for tick marks.

c.TickLabels = classNames;

numClasses = size(cmap,1);


% Center tick labels.

c.Ticks = 1/(numClasses*2):1/numClasses:1;


% Remove tick mark.

c.TickLength = 0;

end


function cmap = camvidColorMap()

% Define the colormap used by CamVid dataset.


cmap = [

    128 128 128   % Sky

    128 0 0       % Building

    192 192 192   % Pole

    128 64 128    % Road

    60 40 222     % Pavement

    128 128 0     % Tree

    192 128 128   % SignSymbol

    64 64 128     % Fence

    64 0 128      % Car

    64 64 0       % Pedestrian

    0 128 192     % Bicyclist

    ];


% Normalize between [0 1].

cmap = cmap ./ 255;

end


function [imdsTrain, imdsVal, imdsTest, pxdsTrain, pxdsVal, pxdsTest] = partitionCamVidData(imds,pxds)

% Partition CamVid data by randomly selecting 60% of the data for training. The

% rest is used for testing.

    

% Set initial random state for example reproducibility.

rng(0); 

numFiles = numpartitions(imds);

shuffledIndices = randperm(numFiles);


% Use 60% of the images for training.

numTrain = round(0.60 * numFiles);

trainingIdx = shuffledIndices(1:numTrain);


% Use 20% of the images for validation

numVal = round(0.20 * numFiles);

valIdx = shuffledIndices(numTrain+1:numTrain+numVal);


% Use the rest for testing.

testIdx = shuffledIndices(numTrain+numVal+1:end);


% Create image datastores for training and test.

imdsTrain = subset(imds,trainingIdx);

imdsVal = subset(imds,valIdx);

imdsTest = subset(imds,testIdx);


% Create pixel label datastores for training and test.

pxdsTrain = subset(pxds,trainingIdx);

pxdsVal = subset(pxds,valIdx);

pxdsTest = subset(pxds,testIdx);

end


function data = augmentImageAndLabel(data, xTrans, yTrans)

% Augment images and pixel label images using random reflection and

% translation.


for i = 1:size(data,1)

    

    tform = randomAffine2d(...

        XReflection=true,...

        XTranslation=xTrans, ...

        YTranslation=yTrans);

    

    % Center the view at the center of image in the output space while

    % allowing translation to move the output image out of view.

    rout = affineOutputView(size(data{i,1}), tform, BoundsStyle='centerOutput');

    

    % Warp the image and pixel labels using the same transform.

    data{i,1} = imwarp(data{i,1}, tform, OutputView=rout);

    data{i,2} = imwarp(data{i,2}, tform, OutputView=rout);

    

end

end


function loss = modelLoss(Y,T,classWeights)

    weights = dlarray(classWeights,"C");

    mask = ~isnan(T);

    T(isnan(T)) = 0;

    loss = crossentropy(Y,T,weights,Mask=mask,NormalizationFactor="mask-included");

end


classes = getClassNames()


imageSize = [720 960 3];

numClasses = 11;

net = deeplabv3plus(imageSize, numClasses, 'mobilenetv2');


I = imread("C:\Anwar\CamVid\train\0001TP_009210.png");


inputSize = net.Layers(1).InputSize;

I = imresize(I,inputSize(1:2));


C = semanticseg(I,net);


cmap = camvidColorMap;

B = labeloverlay(I,C,Colormap=cmap,Transparency=0.4);

figure

imshow(B)

pixelLabelColorbar(cmap, classes);


labelIDs = camvidPixelLabelIDs();

labelDir = fullfile(outputFolder,"train_labels");

pxds = pixelLabelDatastore(labelDir,classes,labelIDs);


C = readimage(pxds,200);

cmap = camvidColorMap;

B = labeloverlay(I,C,ColorMap=cmap);

imshow(B)

pixelLabelColorbar(cmap,classes);


tbl = countEachLabel(pxds)


frequency = tbl.PixelCount/sum(tbl.PixelCount);


bar(1:numel(classes),frequency)

xticks(1:numel(classes)) 

xticklabels(tbl.Name)

xtickangle(45)

ylabel("Frequency")


valdir = fullfile(outputFolder, 'val\')

imdsVal = imageDatastore(valdir)

vallabelDir = fullfile(outputFolder,"val_labels\");

pxdsVal = pixelLabelDatastore(vallabelDir,classes,labelIDs);


dsTrain = combine(imds, pxds)

dsVal = combine(imdsVal, pxdsVal)


xTrans = [-10 10];

yTrans = [-10 10];

dsTrain = transform(dsTrain, @(data)augmentImageAndLabel(data,xTrans,yTrans));


imageSize = [720 960 3];

numClasses = numel(classes);

net = deeplabv3plus(imageSize, numClasses, 'mobilenetv2');


imageFreq = tbl.PixelCount ./ tbl.ImagePixelCount;

classWeights = median(imageFreq) ./ imageFreq;


function iou = computeIoU(YTrue, YPred)

    % Convert predictions to binary mask (assuming single class for simplicity)

    YPred = YPred > 0.5; % Threshold predictions

    intersection = sum((YPred & YTrue), 'all');

    union = sum((YPred | YTrue), 'all');

    

    if union == 0

        iou = 1; % Perfect match (or no objects in both)

    else

        iou = intersection / union;

    end

end


options = trainingOptions("sgdm", ...

    LearnRateSchedule="piecewise", ...

    LearnRateDropPeriod=6, ...

    LearnRateDropFactor=0.1, ...

    Momentum=0.9, ...

    InitialLearnRate=1e-2, ...

    L2Regularization=0.005, ...

    ValidationData=dsVal, ...

    MaxEpochs=18, ...

    MiniBatchSize=4, ...

    Shuffle="every-epoch", ...

    CheckpointPath="C:\Anwar\CamVid\", ...

    VerboseFrequency=10, ...

    ValidationPatience=4, ...

    Metrics = { "accuracy", @computeIoU }, ...

    Plots="training-progress");  % Enable training graphs


doTraining = true;

if doTraining

    [net,info] = trainnet(dsTrain,net,@(Y,T) modelLoss(Y,T,classWeights),options);

end




testimgDir = fullfile(outputFolder,'test\');

imdsTest = imageDatastore(testimgDir);


testlabelDir = fullfile(outputFolder,"test_labels\");

pxdsTest = pixelLabelDatastore(testlabelDir,classes,labelIDs);


I = readimage(imdsTest,35);

C = semanticseg(I,net,Classes=classes);


B = labeloverlay(I,C,Colormap=cmap,Transparency=0.4);

imshow(B)

pixelLabelColorbar(cmap, classes);


expectedResult = readimage(pxdsTest,35);

actual = uint8(C);

expected = uint8(expectedResult);

imshowpair(actual, expected)


iou = jaccard(C,expectedResult);

table(classes,iou)


pxdsResults = semanticseg(imdsTest,net, ...

    Classes=classes, ...

    MiniBatchSize=4, ...

    WriteLocation=tempdir, ...

    Verbose=false);


metrics = evaluateSemanticSegmentation(pxdsResults,pxdsTest,Verbose=false);


metrics.DataSetMetrics


metrics.ClassMetrics


testData = combine(imdsTest, pxdsTest)


function meanIoU = computeTestmIoU(net, testData, classes)

    % Initialize IoU computation

    numClasses = numel(classes);

    intersection = zeros(numClasses, 1);

    union = zeros(numClasses, 1);

    

    % Reset the datastore before looping

    reset(testData);


    % Loop through test data

    while hasdata(testData)

        % Read a batch (image, ground truth mask)

        data = read(testData);

        img = data{1};  % Test image

        trueMask = data{2};  % Ground truth mask

        

        % Get network prediction

        predMask = semanticseg(img, net);


        % Compute IoU for each class

        for c = 1:numClasses

            % Get binary masks for class c

            predClass = (predMask == classNames(c));

            trueClass = (trueMask == classNames(c));


            % Compute intersection and union

            intersection(c) = intersection(c) + sum(predClass(:) & trueClass(:));

            union(c) = union(c) + sum(predClass(:) | trueClass(:));

        end

    end

    

    % Compute IoU for each class and take mean

    IoU = intersection ./ (union + eps); % Avoid division by zero

    meanIoU = mean(IoU, 'omitnan');

    

    % Display result

    fprintf('Overall Test mIoU: %.4f\n', meanIoU);

end



testmIoU = computeTestmIoU(net, testData, classes);



Thursday, January 9, 2025

Importing a MATLAB Semantic Segmentation Model into a TensorFlow Environment and Running It

Steps for Importing and Running a MATLAB Semantic Segmentation Model in a TensorFlow Environment

Building a DeepLabV3+ Model in MATLAB

To build the DeepLabV3+ model in MATLAB using ResNet-18 as the backbone, you can follow the steps below:

  1. Set the image size and number of classes: Define the size of the input images and the number of classes for your semantic segmentation task. In this case, the image size is 720x960 with 3 color channels, and the number of classes is 32.  Build the network: Use the deeplabv3plus function to build the model with the specified image size, number of classes, and ResNet-18 backbone.

Here is the MATLAB code for building the DeepLabV3+ model:

matlab
% Set image size and number of classes imageSize = [720 960 3]; numClasses = 32; % Build the DeepLabV3+ network with ResNet-18 backbone network = deeplabv3plus(imageSize, numClasses, 'resnet18');
network = deeplabv3plus(imageSize, numClasses, 'mobilenetv2');
network = deeplabv3plus(imageSize, numClasses, "xception");
network = deeplabv3plus(imageSize, numClasses, 'InceptionResNetV2');
network = deeplabv3plus(imageSize, numClasses, 'resnet50');

This code will create a DeepLabV3+ model for semantic segmentation with the specified input image size and output class count, using ResNet-18 as the backbone architecture.

  1. Export the Network to TensorFlow: Use the exportNetworkToTensorFlow function to export the model to TensorFlow format. The exported model will be saved in the Python package myModel.
matlab
exportNetworkToTensorFlow(net,"myModel");

To export from the tempdir: if the model in tempdir named "net_1" then export to tensorflow by
exportNetwrorkToTensorFlow(net_1, "ModelName")
  1. Load the Exported TensorFlow Model in Python: In Python, use the following code to load the exported TensorFlow model from the myModel package. The saved model should be copied and pasted to the folder where the ipynb file is located. 
python
import myModel model = myModel.load_model()
  1. Save the Exported Model in TensorFlow SavedModel Format: Saving the model in the SavedModel format is optional. You can directly perform deep learning workflows with the model. However, if you'd like to save it in the SavedModel format, use the following code:
python
model.save("myModelTF")

Wednesday, March 31, 2021



         






          dimension x(10)  ,Y(10)
          print*, 'enter value of dimension x'
          do i = 1,10
          read(*,*) x(i)
          end do
          write(*,*) 'Enter the value of the dimension y'
          do j= 1,10
          read(*,*) y(j)
          End do
          sumx=0
          sumy=0
          do i=1,10
            sumx=sumx+x(i)
            sumy=sumy+y(i)
          enddo
          avex=sumx/10.0
          avey=sumy/10.0
          sum1=0
          sum2=0
          spxy=0
          do i=1,10
            sum1=sum1+(x(i)-avex)**2
            sum2=sum2+(y(i)-avey)**2
            spxy=spxy+(x(i)-avex)*(y(i)-avey)
         end do
         correlation= spxy/sqrt(sum1*sum2)
         Byx=spxy/sum1
         A=avey-(Byx*avex)
         print*, 'the value of corr',correlation,'      ','Byx is=',Byx
         print*, 'and the value of coffecient A is =', a
         print*, 'average of x is', avex,'    ',' and average of y is',avey
         stop
         end

Life cycle of Nematode

Objectives of Urine collection:
        To obtain laboratory results that provides prevalence estimate of disease, risk factor for exam components and bone line information on health and nutritional status of the population.
Collection technique of urine:
1.Natural micturation.
2.Manual compression of bladder.
3.Catheterization.
4.cystocentesis.

Micturation

Definition of micturation:
It is a process by which urine is evacuated from urinary bladder.

Mechanism of micturation:
Sympathetic nerve

Stretching of transitional epithelium

Urine

Increase pressure 30mmhg

Activation of stress recsptors

Sensory nerve

Brain

Parasympathetic motor nerve

Acetylcholine

Contraction of bladder muscle

Relaxation of spincters

Micturation



Contradiction of normal micturation :
When we have to urinate frequently the condition is called polyuria.When we are up frequently during the night the condition is called nocturnal polyuria or nocturia.
Frequent urination can cause problems at work and socializing.The constant fear of use the bathroom can effect one everyday life and happiness and nocturia can cause many sleepless night.
Nocturia increases risk of death.

Abnormal micturation:
Interruption of afferent nerves:
Tabes dorsali's interruption of dorsal roots - reflex construction of the bladder lost - distended, them and hypotonic  - there are some contraction due to intrinsic response in the muscle.
Interruption of both afferent and efferent:
Tumors - Bladder is flacid and distended - shrunken and pertrophied.

Frequent urination indicates:
     1.Infection in bladder.
      2.Infection in urethra.
      3.Infection in kidney.
      4.Bladder stones.
      5.Diabetes.
      6.Tumor in pelvis.
      7.Bladder cancer.
      8.Sign of stroke.


Manual compression of the urinary bladder:
Introduction:
 Manual compression of the bladder can be used to indicate urination in dogs and cats. Application of steady gentle pressure should result in relaxation of urethral sphincter and flow of urine, provided there is adequate urine in the bladder and patent outflow tract.
Procedure:
1) Identify the bladder in the caudal abdomen by palpation.
2) Apply moderate digital pressure to either side of the bladder as possible with fingers and thumb of one hand on with the fingers of both hands and gradually increase pressure until the urine is voided.
3) Collected the urine in a sterile universal container.
Advantages:
This method is often used in patients unable to urinate such as neurological and spinal patients.
It is a quick and easy method in animals.
Provides method for obtaining urine sample when voluntary micturation has occurred.
The risk of iatrogenic urinary tract infection and iatrogenic trauma is minimal.
Disadvantages:
The urinary bladder may traumatized if excessive digital pressure is used. This is not only detrimental to the patient, the associated hematuria may interfere with interpretation is result.
The urinary bladder may not contain a sufficient volume of urine to facilitate this technique.
Samples are frequently contaminated with cells, bacteria and other debris located in the genital tract or on the skin and hair.
Precautions:
Care must not be taken to avoid the rupturing the thin walled bladder particularly as urethral obstruction may be present in animal that present in stranguria or hematuria.
Try to direct the force towards the of the urinary bladder.
Steady continous pressure should be applied rather than forceful intermittent squeezing motions.
Obtain appropriate information to be sure that complete obstraction of the urethra does not exist.
Note:
 If the animal does not urinate during manual expression be ready to collect a voided sample because many animal in this situation will urinate soon after being returned to their house.





Catheterization

Indication:
Diagnostic catheterization may be indicated to :
Collect bladder urine for analysis or bacterial culture.
Determine the volume of residual urine in patients with suspected neurogenic inconfinence.
For renal functions studies.
Evaluate the lumen for calculi, strictures.
Instill constant media for constant radiography.

Therapeutic catheterization may be indicated to:
Instill the medications into the urinary bladder.
Relieve obstruction to urine flow.
Facilitate the surgical repair of the urethra or surrounding structures.

Types of catheter:
Rigid metal canine female urethral catheter.
Folsy self-retaining catheter with valve.
Canine flexible urethral catheter.
Olive tip human urethral catheter.
Blasucci human urethral catheter with flexible filiform tip.
Blasucci tip human urethral catheter.
Right metal lacrimal cannula.
Silver abscess cannula.
Tomcat catheter.
Open end tomcat catheter.
Intradermic polyethylene tubing with one end flared.

Care of urinary catheter:
Only sterilized catheters that are in excellent condition should be used. Weakened rough external surface should be avoided.
Catheters should be individually packaged prior to use.
Non-sterilized catheter should never be used because they may cause introgenic infection & contaminate the urine.
Catheter must be sterilized by autoclaving and by using
Ethylene oxide (best)
Quaternary ammonium compounds.



Potential complications:
Trauma :
Trauma to the urinary tract avoided by selection of smooth flexible catheters and a good technique.
Haematuria indicates poor equipment or technique’
Trauma leads to bacterial infection that damage the body defensive mechanism.

Infections:
A resident population of bacteria (mainly streptococci & staphylococci) and mycoplasma are normally present in the urethra.
By systemic natural defense mechanisms of kidneys, ureters & urinary bladder prevent the urinary tract infections in normal animal.
Preventable causes of bacterial infections of the urinary bladder associated with catheterization include:
Inadequate cleansing of the peri-urethral tissues.
Use of non-sterilized equipment.
Catheter induced trauma to the mucosa of ureter &   bladder.
When necessary for diagnostic or therapeutic purposes, carefully executed catheterization of the urinary bladder should be performed without hesitation.
Reduce the incidence of introgenic infection by :
Avoiding indiscriminate use of the technique.
Allowing only properly trained personnel to perform the procedure.
Irritation of the bladder with antibacterial solutions (neomycin, furacin, polymyxin etc.

Use of catheters impregnated with antibacterial agents designated for man.



Equipments of catheterization:
Sterile gloves - consider universal precautions
Sterile drapes
Cleansing solution e.g. Savlon
Cotton swabs
Forceps
Sterile water
Foley catheter
Syringe
Lubricant
Collection bag and tubing.



Procedure:
Steps are to…….
Gather equipment.
Open catheterization kit and catheter
Prepare sterile field, apply sterile gloves
Check balloon for patency.
Generously coat the distal portion (2-5 cm) of the catheter with lubricant
Apply sterile drape
If female, separate labia using non-dominant hand. If male, hold the penis with the non-dominant hand. Maintain hand position until preparing to inflate balloon.
Using dominant hand to handle forceps, cleanse peri-urethral mucosa with cleansing solution. Cleanse anterior to posterior, inner to outer, one swipe per swab, discard swab away from sterile field.
Pick up catheter with gloved (and still sterile) dominant hand. Hold end of catheter loosely coiled in palm of dominant hand.
In the male, lift the penis to a position perpendicular to patient's body and apply light upward traction (with non-dominant hand)
Identify the urinary meatus and gently insert until 1 to 2 inches beyond where urine is noted
Inflate balloon, using correct amount of sterile liquid (usually 10 cc but check actual balloon size)
Gently pull catheter until inflation balloon is snug against bladder neck
Connect catheter to drainage system
Secure catheter to abdomen or thigh, without tension on tubing
Place drainage bag below level of bladder
Evaluate catheter function and amount, color, odor, and quality of urine
Remove gloves, dispose of equipment appropriately, wash hands
Document size of catheter inserted, amount of water in balloon, patient's response to procedure, and assessment of urine


Cystosentesis
Cystocentesis:
Cystocentesis is a urinary procedure where a needle is placed into the urinary bladder through the abdomen of a animal and a sample of urine is removed. Diagnostic cystocentesis is used to present sample taken  for urinalysis from being contaminated with bacteria, cells and debris from lower urogenital tract.
Symptoms of cystocentesis:
       ~Duffuculty urinating.
       ~Urinating out of the litter box.
       ~Painfull urination.
      ~Blood in the urine.
      ~Reduced playfulness.
Indication:
~Routine collection of urine samples for urinalysis or urine culture.
~Immediate relief of bladder over distention in animals with urethral obstruction.
Contradiction:
~Coagulopathy.
~Pregnancy.
~Confirmed transitional cell carcinoma.
~Severe and diffuse cutaneous disease of abdomen.
Potential complication
~Seeding of transitional cell carcinoma and tumor cells into the abdomen or along the needle track.
~Transient hematuria.
~Bladder rupture.



EQUIPMENTS:
1) We routinely  use 22-gauge needles. Depending on  the size  of the patient  and the distance  of the ventral bladder  wall  from the  ventral  abdominal wall .1.5 inches hypodermic  or 3 inches  spinal needles  may be needed.
2) Small capacity  (2.5 to 12ml) syringes are usually employed for diagnostic  cystocentesis, while large  capacity(20-60 ml)syringes are used  for therapeutic  cystocentesis . Alternatively, therapeutic  cystocentesis  may be performed  with  6-12 ml syringes  and a  2-way or 3-way valve.
SITE:
1) Careful planning  of the  site and  direction  of  needle  puncture  of  the  bladder   wall is recommended. The needle  is inserted  in the  ventral  or  ventro-lateral  wall of the urinary bladder,in order to minimize the  chance  of  trauma  to  the  ureters  and  major  abdominal  vessels.
2) If therapeutic cystocentesis  is  to be  performed, recommended  insertion  of  the  needle a short  distance  cranial  to  the  of  the bladder with the  urethra rather than at  the  vertex  of  the bladder. This  will  permit  removal  of  urine  and  decompression  of  the  bladder  without  need  for  re-insertion  of  the  needle  into  the  bladder  needle.
3) The  needle  will be  directed  through  the  bladder  wall at  approximately  at  45 degree  angle so that oblique  needle  tract  will  be  created.
TECHNIQUE:
1) In order  to  perform  cystocentesis  without  risk  to  the  patient  deliberate planning  of  the  site  and  direction  of  the  needle  puncture  is  essential.The  bladder  must  contain  a  sufficient  volume  of  urine  to permite  immobilization  and  localization  by  palpation. Excessive   hair should be removed with scissors or clippers. The  ventral  abdominal skin  penetrated  by  the  needle  should  be  cleansed  with  an  antiseptic  solution   each time  cystocentesis  is performed.
2)In case   of cat, it is  usually  easier  to  perform  the  procedure  with  the  patient   in  lateral  or dorsal  recumbency.
3)In dogs, the procedure  may be  performed when  the  patient is  standing.
4)Following  localization  and   immobilization  of  the  urinary  bladder  the  needle  should  ne  inserted  through  the  ventral  abdominal  wall  and  advanced to  the  caudo-ventral aspect  of the  bladder. The needle should  be  inserted  through  the  bladder  wall at an  oblique  angle.
5.excessive digital pressure should not be applied to the bladder wall while the needle is in its lumen in order to prevent urine from being forced around the needle into the peritoneal cavity.
6. An appropriate quantity of urine for analysis of analysis and/or bacterial culture should be aspirated into the syringe. If disease of the bladder wall or virulence of urine pathogens is a likely cause of complications associated with loss of urine into the peritoneal cavity, the bladder should be emptied as completely as is consistent with atraumatic technique. These potenytial complications have not been a problem in patients.
7. Use of a prophylactic antibacterial therapy following cystocentesis must be determined on the basis of the status of the patient and retrospective evaluation of technique.
8. In order to minimize contamination of the peritoneal cavity with urine , unnecessary digital pressure should not be applied to the urinary bladder following cystocentesis.
9. In case of rabbit,
        a) Restrain and position  the rabbit since excellent restraint is critical if the rabbit is conscious. So, have the rabbit restrained in dorsal recumbency.
       b) Locate the bladder by pulpating just cranial to the pelvic brim on the ventral midline.
       c) Assess the bladder volume.
d) Clip the fur.
e) Disinfect the skin.
f) Isolate the bladder.
g) Direct a small needle attached to a syringe into the bladder.
h) Retract the syringe plunger slowly.
i) Transfer the urine sample to an appropriate container.

Precaution:
-In most domestic rabbit there is no need for sedation. However sedation for anaesthesia will prevent the rabbit for struggling and reduce the rise of damage to the internal structures.
- Repeated puncture of the bladder can result in inflammation and subsequent stone formation.
- Precaution should be taken to avoid introgenic trauma/infection of urinary bladder and surrounding.

-potential complications include damage to the bladder wall or adjacent structures with the needle, local or generalized peritonitis, vesicoperitoneal fistulas and adhesion of adjacent structures to the bladder wall.
- penetration of loop of intestine by the needle may result in false positive significant bacteriurea and varying degrees of microscopic hematuria might be expected for a short period of time following cystocentesis.






Tuesday, March 19, 2013

Fortran 95

Main article: Fortran 95 language features

Fortran 95, published officially as ISO/IEC 1539-1:1997, was a minor revision, mostly to resolve some outstanding issues from the Fortran 90 standard. Nevertheless, Fortran 95 also added a number of extensions, notably from the High Performance Fortran specification:
  • FORALL and nested WHERE constructs to aid vectorization
  • User-defined PURE and ELEMENTAL procedures
  • Default initialization of derived type components, including pointer initialization
  • Expanded the ability to use initialization expressions for data objects
  • Clearly defined that ALLOCATABLE arrays are automatically deallocated when they go out of scope.
A number of intrinsic functions were extended (for example a dim argument was added to the maxloc intrinsic).
Several features noted in Fortran 90 to be "obsolescent" were removed from Fortran 95:
  • DO statements using REAL and DOUBLE PRECISION variables
  • Branching to an END IF statement from outside its block
  • PAUSE statement
  • ASSIGN and assigned GOTO statement, and assigned format specifiers
  • H edit descriptor.
An important supplement to Fortran 95 was the ISO technical report TR-15581: Enhanced Data Type Facilities, informally known as the Allocatable TR. This specification defined enhanced use of ALLOCATABLE arrays, prior to the availability of fully Fortran 2003-compliant Fortran compilers. Such uses include ALLOCATABLE arrays as derived type components, in procedure dummy argument lists, and as function return values. (ALLOCATABLE arrays are preferable to POINTER-based arrays because ALLOCATABLE arrays are guaranteed by Fortran 95 to be deallocated automatically when they go out of scope, eliminating the possibility of memory leakage. In addition, aliasing is not an issue for optimization of array references, allowing compilers to generate faster code than in the case of pointers.)
Another important supplement to Fortran 95 was the ISO technical report TR-15580: Floating-point exception handling, informally known as the IEEE TR. This specification defined support for IEEE floating-point arithmetic and floating point exception handling.

Conditional compilation and varying length strings

In addition to the mandatory "Base language" (defined in ISO/IEC 1539-1 : 1997), the Fortran 95 language also includes two optional modules:
  • Varying character strings (ISO/IEC 1539-2 : 2000)
  • Conditional compilation (ISO/IEC 1539-3 : 1998)
which, together, compose the multi-part International Standard (ISO/IEC 1539).
According to the standards developers, "the optional parts describe self-contained features which have been requested by a substantial body of users and/or implementors, but which are not deemed to be of sufficient generality for them to be required in all standard-conforming Fortran compilers." Nevertheless, if a standard-conforming Fortran does provide such options, then they "must be provided in accordance with the description of those facilities in the appropriate Part of the Standard."

Fortran 90

The much delayed successor to FORTRAN 77, informally known as Fortran 90 (and prior to that, Fortran 8X), was finally released as ISO/IEC standard 1539:1991 in 1991 and an ANSI Standard in 1992. In addition to changing the official spelling from FORTRAN to Fortran, this major revision added many new features to reflect the significant changes in programming practice that had evolved since the 1978 standard:

  • Free-form source input, also with lowercase Fortran keywords
  • Identifiers up to 31 characters in length
  • Inline comments
  • Ability to operate on arrays (or array sections) as a whole, thus greatly simplifying math and engineering computations.
    • whole, partial and masked array assignment statements and array expressions, such as   X(1:N)=R(1:N)*COS(A(1:N))
    • WHERE statement for selective array assignment
    • array-valued constants and expressions,
    • user-defined array-valued functions and array constructors.
  • RECURSIVE procedures
  • Modules, to group related procedures and data together, and make them available to other program units, including the capability to limit the accessibility to only specific parts of the module.
  • A vastly improved argument-passing mechanism, allowing interfaces to be checked at compile time
  • User-written interfaces for generic procedures
  • Operator overloading
  • Derived (structured) data types
  • New data type declaration syntax, to specify the data type and other attributes of variables
  • Dynamic memory allocation by means of the ALLOCATABLE attribute and the ALLOCATE and DEALLOCATE statements
  • POINTER attribute, pointer assignment, and NULLIFY statement to facilitate the creation and manipulation of dynamic data structures
  • Structured looping constructs, with an END DO statement for loop termination, and EXIT and CYCLE statements for terminating normal DO loop iterations in an orderly way
  • SELECT . . . CASE construct for multi-way selection
  • Portable specification of numerical precision under the user's control
  • New and enhanced intrinsic procedures.

Obsolescence and deletions

Unlike the previous revision, Fortran 90 did not delete any features. (Appendix B.1 says, "The list of deleted features in this standard is empty.") Any standard-conforming FORTRAN 77 program is also standard-conforming under Fortran 90, and either standard should be usable to define its behavior.
A small set of features were identified as "obsolescent" and expected to be removed in a future standard.
Obsolescent feature Example Status / Fate in Fortran 95
Arithmetic IF-statement     IF (X) 10, 20, 30
Non-integer DO parameters or control variables     DO 9 X= 1.7, 1.6, -0.1 Deleted
Shared DO-loop termination or
termination with a statement
other than END DO or CONTINUE  
    DO 9 J= 1, 10         DO 9 K= 1, 10
9   L= J + K


Branching to END IF
from outside a block
66  GO TO 77 ; . . .     IF (E) THEN ;     . . .
77  END IF

Deleted
Alternate return     CALL SUBR( X, Y *100, *200 )
PAUSE statement     PAUSE 600 Deleted
ASSIGN statement
  and assigned GO TO statement
100  . . .     ASSIGN 100 TO H
    . . .
    GO TO H . . .

Deleted
Assigned FORMAT specifiers     ASSIGN F TO 606 Deleted
H edit descriptors 606 FORMAT ( 9H1GOODBYE. ) Deleted
Computed GO TO statement     GO TO (10, 20, 30, 40), index (obsolete)
Statement functions     FOIL( X, Y )= X**2 + 2*X*Y + Y**2 (obsolete)
DATA statements
  among executable statements
    X= 27.3     DATA A, B, C / 5.0, 12.0. 13.0 /     . . .
(obsolete)
CHARACTER* form of CHARACTER declaration     CHARACTER*8 STRING   ! Use CHARACTER(8) (obsolete)
Assumed character length functions     CHARACTER*(*) STRING (obsolete)[14]
Fixed form source code Column 1 contains *, ! or C for comments.
Column 6 for continuation.

"Hello world" example

program helloworld
     print *, "Hello, world."
end program helloworld

FORTRAN 77

After the release of the FORTRAN 66 standard, compiler vendors introduced a number of extensions to "Standard Fortran", prompting ANSI committee X3J3 in 1969 to begin work on revising the 1966 standard, under sponsorship of CBEMA, the Computer Business Equipment Manufacturers Association (formerly BEMA). Final drafts of this revised standard circulated in 1977, leading to formal approval of the new FORTRAN standard in April 1978. The new standard, known as FORTRAN 77 and officially denoted X3.9-1978, added a number of significant features to address many of the shortcomings of FORTRAN 66:

  • Block IF and END IF statements, with optional ELSE and ELSE IF clauses, to provide improved language support for structured programming
  • DO loop extensions, including parameter expressions, negative increments, and zero trip counts
  • OPEN, CLOSE, and INQUIRE statements for improved I/O capability
  • Direct-access file I/O
  • IMPLICIT statement
  • CHARACTER data type, with vastly expanded facilities for character input and output and processing of character-based data
  • PARAMETER statement for specifying constants
  • SAVE statement for persistent local variables
  • Generic names for intrinsic functions
  • A set of intrinsics (LGE, LGT, LLE, LLT) for lexical comparison of strings, based upon the ASCII collating sequence. (These ASCII functions were demanded by the U.S. Department of Defense, in their conditional approval vote.[citation needed])
In this revision of the standard, a number of features were removed or altered in a manner that might invalidate previously standard-conforming programs. (Removal was the only allowable alternative to X3J3 at that time, since the concept of "deprecation" was not yet available for ANSI standards.) While most of the 24 items in the conflict list (see Appendix A2 of X3.9-1978) addressed loopholes or pathological cases permitted by the previous standard but rarely used, a small number of specific capabilities were deliberately removed, such as:
GREET = 12HHELLO THERE!
  • Reading into an H edit (Hollerith field) descriptor in a FORMAT specification.
  • Overindexing of array bounds by subscripts.
DIMENSION A(10,5)
Y= A(11,1)
  • Transfer of control out of and back into the range of a DO loop (also known as "Extended Range").

Variants: Minnesota FORTRAN

Control Data Corporation computers had another version of FORTRAN 77, called Minnesota FORTRAN (MNF), designed especially for student use, with variations in output constructs, special uses of COMMONs and DATA statements, optimizations code levels for compiling, and detailed error listings, extensive warning messages, and debugs.[11]

Transition to ANSI Standard Fortran

The development of a revised standard to succeed FORTRAN 77 would be repeatedly delayed as the standardization process struggled to keep up with rapid changes in computing and programming practice. In the meantime, as the "Standard FORTRAN" for nearly fifteen years, FORTRAN 77 would become the historically most important dialect.
An important practical extension to FORTRAN 77 was the release of MIL-STD-1753 in 1978.[12] This specification, developed by the U.S. Department of Defense, standardized a number of features implemented by most FORTRAN 77 compilers but not included in the ANSI FORTRAN 77 standard. These features would eventually be incorporated into the Fortran 90 standard.
The IEEE 1003.9 POSIX Standard, released in 1991, provided a simple means for FORTRAN 77 programmers to issue POSIX system calls.[13] Over 100 calls were defined in the document — allowing access to POSIX-compatible process control, signal handling, file system control, device control, procedure pointing, and stream I/O in a portable manner.